Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Selecting Ranges using Variables
I currently have Sheet2 active in this example:
Sub TestIt() Dim Line as Integer Line = 8 x = 1 While Cells(x,1) < "" Sheets("Sheet1").Range("A" & Line & ":K" & Line).Select x = x + 1 Wend End Sub I get an error on the Select statement "Select Method of Range Class Failed". I am trying to select Range("ALine:KLine") where Line is the variable. Any help would be great. DG |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Selecting Ranges using Variables
You need to have "Sheet1" active to select the range. Try this...
Sub TestIt() Dim Line As Integer Dim x as Integer Line = 8 x = 1 Worksheets("Sheet1").Activate While Worksheets("Sheet2").Cells(x, 1) < "" Worksheets("Sheet1").Range("A8:K8").Select x = x + 1 Wend End Sub "DG" wrote: I currently have Sheet2 active in this example: Sub TestIt() Dim Line as Integer Line = 8 x = 1 While Cells(x,1) < "" Sheets("Sheet1").Range("A" & Line & ":K" & Line).Select x = x + 1 Wend End Sub I get an error on the Select statement "Select Method of Range Class Failed". I am trying to select Range("ALine:KLine") where Line is the variable. Any help would be great. DG |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Selecting Rows using Long Variables | Excel Discussion (Misc queries) | |||
problem selecting a range using variables | Excel Programming | |||
Selecting Non-Consecutive Variables | Excel Discussion (Misc queries) | |||
Using Ranges to input variables to UDF | Excel Programming | |||
using variables to set ranges | Excel Programming |