Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Using a variable to select a cell on a worksheet..."Subscript out orrange"
See code below. I know this is pretty simple, but what I'm trying to
do is pull data from a cell (in the test.xls spreadsheet) that has a varying (based upon what someone writes in the cell) text input. I then want the macro I run to reference this cell to select which worksheet it is going to select in the spreadsheet in which I'm running the macro. Dim rng As RangeDim ws1 As Worksheet Dim WhichSheetCell As String WhichSheetCell = Workbooks.Open("Z:\Invoices \test.xls").Worksheets("Sheet1").Cells(3, 2) Set ws1 = Sheets("WhichSheetCell") Set rng = ws1.Range("A1:N" & Rows.Count) I get a "subscript out of range" error when I run it. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell | Excel Discussion (Misc queries) | |||
Range("C100:D200").Select with variable names | Excel Programming | |||
Format Cell to show "-1" in subscript | Excel Discussion (Misc queries) | |||
use variable in Workbooks("book1").Worksheets("sheet1").Range("a1" | Excel Programming | |||
"Subscript out of range" error for: Workbooks("Test1.xls").Save | Excel Programming |