Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
My problem is trying to use a range variable with the Cells object. See the
code sample code below. I am trying to copy a group of cells from a sheet that is not active. it works if I reference one cell but not more than one. I can't seem to get the syntax right. hel would be appreciated. Sub UseARangeVariable() Dim MyRange As Range Sheets("Rota").Select Range("A10").Select Set MyRange = ActiveCell.CurrentRegion Sheets("Sheet1").Select 'Change Sheets MyRange.Cells(1, 1).Copy 'Refer to first sheet i.e. Rota Range("a1").Select ActiveSheet.Paste 'But Paste to sheet1...this works MyRange.Range(Cells(1, 2), Cells(1, 7)).Copy 'Try to do same with cell range Range("a2").Select 'but causes 1004 error ActiveSheet.Paste End Sub -- Alan |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Defining a Range using Variables | Excel Discussion (Misc queries) | |||
Sum a range based on two variables | Excel Worksheet Functions | |||
How do I select on two variables in a range of data in excel | Excel Worksheet Functions | |||
Add up a Dynamic Range with 2 Variables | Excel Worksheet Functions | |||
Range Variables | Excel Programming |