Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Workbook.Range Problem
I have a workbook that when I click a button it runs a macro that
allows me to open up another workbook of my choice, then copy a certain range in the newly opened workbook and paste it into my workbook that ran the macro. My question is, How can I set a range in my newly opened workbook as a variable. It works when I do it like this. ______________________________________________ Windows("MyNewlyOpenedWorkbook").Activate Range("A1:A5").Select Selection.Copy Windows("MyWorkbookWithMacro").Activate Range("A1:A5").Select Selection.Paste ______________________________________________ What I would like to be able to do is something like this: Dim rCopyRange As Range Dim rPasteRange As Range Set rCopyRange = MyNewlyOpenedWorkbook.Range("A1:A5") Set rPasteRange = Range("A1:A5") Windows(sOpenJobFileName).Activate rCopyRange.Select Selection.Copy Windows("BIDPROG9.xls").Activate rPasteRange.Select Selection.Paste _____________________________________________ So again I ask. How can I name a range on my newly opened workbook? Any input would relieve this building headache I'm working on. Thanks |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Workbook.Range Problem
Thanks Dave that worked great.
Now my worksheet name in the newly opened workbook is different depending on the workbook opened but there is always only one worksheet in the workbook. Is there a variable I can use to get the worksheet name |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Workbook.Range Problem
If it's always the first (and only sheet):
set rngtocopy = newwkbk.worksheets(1).range("a1:a5") wrote: Thanks Dave that worked great. Now my worksheet name in the newly opened workbook is different depending on the workbook opened but there is always only one worksheet in the workbook. Is there a variable I can use to get the worksheet name -- Dave Peterson |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Workbook.Range Problem
Thanks Dave, again that worked great.
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Copy a Range from each workbook - Ron de Bruin VBA - a problem | Excel Worksheet Functions | |||
Name assigned in workbook refers to range problem!!! | Excel Programming | |||
Problem copying a range to a different workbook | Excel Programming | |||
Excel VBA - Range.Replace within workbook over several sheets problem | Excel Programming | |||
Excel Macro Problem, Add-in need to work in every workbook & Error:9 Subscript out of range | Excel Programming |