How can I include a workbook name when specifying a Range in VBA code? Thanks, Keith
K keithb Aug 5, 2005 #1 How can I include a workbook name when specifying a Range in VBA code? Thanks, Keith
N Norman Jones Aug 5, 2005 #2 Hi Heith, One way: Sub Tester08() Dim WB As Workbook Dim WS As Worksheet Dim Rng As Range Set WB = Workbooks("MyWorkBook") Set WS = WB.Sheets("MysheetName") Set Rng = WS.Range("A1100") End Sub
Hi Heith, One way: Sub Tester08() Dim WB As Workbook Dim WS As Worksheet Dim Rng As Range Set WB = Workbooks("MyWorkBook") Set WS = WB.Sheets("MysheetName") Set Rng = WS.Range("A1100") End Sub
N Norman Jones Aug 5, 2005 #3 Hi Keith, Just to add, if the workbook has previously been saved, then you must include the extension (e.g.: .xls) in the workbook name. So: Set WB = Workbooks("MyWorkBook") Click to expand... should be in the form: Set WB = Workbooks("MyWorkBook.xls") for a saved workbook.
Hi Keith, Just to add, if the workbook has previously been saved, then you must include the extension (e.g.: .xls) in the workbook name. So: Set WB = Workbooks("MyWorkBook") Click to expand... should be in the form: Set WB = Workbooks("MyWorkBook.xls") for a saved workbook.