P
plz.. its only a simple problem regards copy-paste
Hi there,
I have a little (or big?) problem con a simple copy-paste
macro, what I'm trying to do is to copy an specific range
for one workbook (that is on a different file what I'm
working), and paste it to an specific worksheet, first
empty cell on a column on my actual workbook. I was trying
a lot but it send me an strange "400" error msg (just
400), and because of that I'm trying to make a "cell by
cell" move data (with out paste method), but doesn't work,
could you guys plz help me to find a solution?
..... And for the cell by cell method Im trying this: (it
send me an error message regards the F1 variable, Im
trying to set F1 as string but still doesn't work)
thanks a lot for ur helping
I have a little (or big?) problem con a simple copy-paste
macro, what I'm trying to do is to copy an specific range
for one workbook (that is on a different file what I'm
working), and paste it to an specific worksheet, first
empty cell on a column on my actual workbook. I was trying
a lot but it send me an strange "400" error msg (just
400), and because of that I'm trying to make a "cell by
cell" move data (with out paste method), but doesn't work,
could you guys plz help me to find a solution?
Code:
Sub Actualiza()
ActiveWorkbook.Unprotect
Dim myCurrentWorkbook As Workbook
Dim myDataSourceWorkbook As Workbook
Dim myCurrentWorksheet As Worksheet
Set myCurrentWorkbook = ActiveWorkbook
FileToOpen = Application.GetOpenFilename("Excel Files
(*.xls), *.xls")
Set myDataSourceWorkbook = Workbooks.Open(FileToOpen)
myDataSourceWorkbook.Sheets(1).Range("C2:F2").Copy
Application.DisplayAlerts = False
myDataSourceWorkbook.Close
Application.DisplayAlerts = True
With myCurrentWorkbook.Sheets("H-M")
'Range("D1").End(xlDown).Offset(1, 0).PasteSpecial xlValues
'With myCurrentWorkbook.Sheets("H-M")
...Select
...Range("D1").Select
...Cells(ActiveCell.End(xlDown).Offset(1, 0).Row, 4).Select
ActiveCell.PasteSpecial xlPasteAll
End With
ActiveWorkbook.Protect Structure:=True, Windows:=False
MsgBox "Completada la Tarea", vbOKOnly
End Sub
..... And for the cell by cell method Im trying this: (it
send me an error message regards the F1 variable, Im
trying to set F1 as string but still doesn't work)
Code:
Sub Actualiza7()
Dim F1 As Singe, F2 As Single, F3 As Single, F4 As Single
Dim myDataSourceWorkbook As Workbook
Dim myCurrentWorkbook As Workbook
Dim FileToOpen As String
Dim myDataSourceWorksheet As Worksheet
Dim myCurrentWorksheet As Worksheet
Set myCurrentWorkbook = ActiveWorkbook
FileToOpen = Application.GetOpenFilename("Excel Files
(*.xls), *.xls")
If FileToOpen = "false" Then Exit Sub
Set myDataSourceWorkbook = Workbooks.Open(FileToOpen)
Set myDataSourceWorksheet = myDataSourceWorkbook.Sheets
("Hoja2")
Set F1 = myDataSourceWorksheet.Cells(2, 3).Value
Set F2 = myDataSourceWorksheet.Cells(2, 4).Value
Set F3 = myDataSourceWorksheet.Cells(2, 5).Value
Set F4 = myDataSourceWorksheet.Cells(2, 6).Value
Application.DisplayAlerts = False
myDataSourceWorkbook.Close
Application.DisplayAlerts = True
Application.ScreenUpdating = False
Set myCurrentWorksheet = myCurrentWorkbook.Sheets("H-M")
Set myCurrentWorksheet.Range("D1").End(xlDown).Offset(1,
0).Value = F1
Set myCurrentWorksheet.Range("E1").End(xlDown).Offset(1,
0).Value = F2
Set myCurrentWorksheet.Range("F1").End(xlDown).Offset(1,
0).Value = F3
Set myCurrentWorksheet.Range("G1").End(xlDown).Offset(1,
0).Value = F4
Application.ScreenUpdating = True
End Sub
thanks a lot for ur helping