I wrote a sub to copy one range to another, but it results in error '1004' no matter what I try.
I also Googled for similar problems and searched in stackOverflow, to no avail. quite frustrating.
Hope someone can help me. Here is the code.
Sub CopyColData(rSource As Range, rDest As Range)
' copy 'rSource' to 'rDest'
' NOTE: will force 'rDest' to fit the size of 'rSource'
Set rDest = rDest.Resize(rSource.Rows.Count, rSource.Columns.Count)
rSource.Copy (rDest)
End Sub
Sub CopyColDataTEST()
Sheets.Add.name = "sheet1"
Range("A1").Value = "1AA"
Range("A2").Value = "1BB"
Range("A3").Value = "1CC"
Range("A4").Value = "1DD"
Sheets.Add.name = "sheet2"
CopyColData Worksheets("sheet1").Range("A1:A4"), Worksheets("sheet2").Range("B1")
End Sub
I also tried to copy sheet1 to sheet1, and got the same error.