Thursday, 5 September 2013

Copy Area and Paste Area Aren't The Same Size Error?

Copy Area and Paste Area Aren't The Same Size Error?

The code below gives me run-time error saying that area size aren't the same
I am looking for solutions to copy the Column WITHOUT the header included
(so from a2 to whatever the active cells are). Right now the code below
copiest the entire column from sheet1 to sheet2
I guess i can use range function, but not sure how to properly execute it
in this situation. Thank you
Sub test()
Dim s1 As Worksheet, s2 As Worksheet
Set s1 = Sheets("Sheet1")
Set s2 = Sheets("Sheet2")
c = ActiveCell.Column
s1.Activate
Range("A1").Select
s1.Rows("1:1").Find(What:="Name1", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
s1.Columns(c).Copy s2.Range("a2")
s1.Rows("1:1").Find(What:="Name2", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
s1.Columns(c).Copy s2.Range("c2")
End Sub

No comments:

Post a Comment