Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm working on app where I have to copy data between several books/sheets,
and it's a pain to make sure i'm referencing the correct source/destination. I try to set object references to each of the books/sheets I'm working with and use those to preface the copy/pastes. While doing that I noticed that the range object has a range property, and I wanted to know how to use it. For instance: Set rngTestRange = oSheet.Cells(6, 1) Do Set rngTestRange = rngTestRange.Offset(1, 0) 'check for start of new cost account If Not IsEmpty(rngTestRange.Value) Then sAccount = rngTestRange For x = 1 To oChartSkel.Sheets.Count 'copy chart sheets from skel to this cam's chart notebook oChartSkel.Sheets(x).Copy After:=oThisMgrChartBook.Sheets(1) Set oCurrentChartSheet = ActiveSheet oCurrentChartSheet.Name = sAccount & oChartSkel.Sheets(x).Name 'copy from source to this chart's data oSheet.Range(Cells(rngTestRange.Row + 1, 4), Cells (rngTestRange.Row + 16, 21)).Copy oCurrentChartSheet.Range("B52").PasteSpecial xlPasteValues Next x End If Loop Until rngTestRange.Row = lngLastRow Instead of oSheet.Range(Cells(rngTestRange.Row + 1, 4), Cells(rngTestRange.Row + 16, 21)).Copy Could I have used: rngTestRange.Range(Cells(rngTestRange.Row + 1, 4), Cells(rngTestRange.Row + 16, 21)).Copy is the range property from a sheet the same as the range property from a range? Thanks, Woody |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The Range property of a Range is there to allow you to use addresses relative
to your range's upper left cell. For example, Range(B5:C10).Range("A1") is cell B5, Range(B5:C10).Range("B1") is cell C5, Range(B5:C10).Range("A2") is cell B6, etc. The Worksheet.Range is the entire range on the worksheet, so it uses the row/column references we all "normally" use. "Woody" wrote: I'm working on app where I have to copy data between several books/sheets, and it's a pain to make sure i'm referencing the correct source/destination. I try to set object references to each of the books/sheets I'm working with and use those to preface the copy/pastes. While doing that I noticed that the range object has a range property, and I wanted to know how to use it. For instance: Set rngTestRange = oSheet.Cells(6, 1) Do Set rngTestRange = rngTestRange.Offset(1, 0) 'check for start of new cost account If Not IsEmpty(rngTestRange.Value) Then sAccount = rngTestRange For x = 1 To oChartSkel.Sheets.Count 'copy chart sheets from skel to this cam's chart notebook oChartSkel.Sheets(x).Copy After:=oThisMgrChartBook.Sheets(1) Set oCurrentChartSheet = ActiveSheet oCurrentChartSheet.Name = sAccount & oChartSkel.Sheets(x).Name 'copy from source to this chart's data oSheet.Range(Cells(rngTestRange.Row + 1, 4), Cells (rngTestRange.Row + 16, 21)).Copy oCurrentChartSheet.Range("B52").PasteSpecial xlPasteValues Next x End If Loop Until rngTestRange.Row = lngLastRow Instead of oSheet.Range(Cells(rngTestRange.Row + 1, 4), Cells(rngTestRange.Row + 16, 21)).Copy Could I have used: rngTestRange.Range(Cells(rngTestRange.Row + 1, 4), Cells(rngTestRange.Row + 16, 21)).Copy is the range property from a sheet the same as the range property from a range? Thanks, Woody |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel Addin:Setting the range to the Excel.Range object range prop | Excel Worksheet Functions | |||
Range Question / error 1004: method Range of object Worksheet has failed | Excel Programming | |||
How to use Cells property to Range object? | Excel Programming | |||
using RANGE object in multiple-area range | Excel Programming | |||
Adding named range gives error "method range of object _Global failed " | Excel Programming |