Home |
Search |
Today's Posts |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If you are running the code from a control on a worksheet or a form then it
will be necessary to qualify your Cells references to the specific worksheet. With Sheets("Raw Data") .Range(.Cells(7, Mycol), .Cells(397, Mycol + 4)).Copy Destination:=MyWkBook.Sheets("Raw Data").Range(Myrng) End With Note the dots in front of the Cells keyword that tie the cells directly to the sheet named in the With statement. Otherwise the Cells reference reverts to the object containing the code and will either produce an error or the wrong results. "Charles" wrote in message ... HI, The fowling code does not work as designed Sheets("Raw Data").Range(Cells(7, Mycol), Cells(397, Mycol + 4)).Copy Destination:=MyWkBook.Sheets("Raw Data").Range(Myrng) However if I changed it to Sheets("Raw Data").Range("B7:F397").Copy Destination:=MyWkBook.Sheets("Raw Data").Range(Myrng) It works. MyCol should = 2 because a Find determined that the item I was looking for is in column 2. Any help with this problem would be appreciated. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Copy destination | Excel Programming | |||
Help with copy destination | Excel Programming | |||
VBA .copy destination | Excel Discussion (Misc queries) | |||
Copy Destination fails | Excel Programming | |||
Selection.Copy Destination:= | Excel Programming |