Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
DG DG is offline
external usenet poster
 
Posts: 46
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Selecting Rows using Long Variables pallaver Excel Discussion (Misc queries) 2 July 14th 08 07:13 AM
problem selecting a range using variables cass calculator Excel Programming 3 May 23rd 06 09:43 PM
Selecting Non-Consecutive Variables Colin Vicary Excel Discussion (Misc queries) 3 February 2nd 06 09:01 AM
Using Ranges to input variables to UDF Peter Bradley Excel Programming 3 October 3rd 04 12:14 PM
using variables to set ranges Dave Marden[_2_] Excel Programming 1 December 2nd 03 01:24 AM


All times are GMT +1. The time now is 09:50 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"