Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Selecting a Range Using a Variable

Does anybody know what the marco command(s) are for
selecting a range of cells in a column using a variable?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Selecting a Range Using a Variable

yes, hope this example helps:

Sub SelectRows2To5InCol()
Dim Col
Col = 3
Range(Cells(2, Col), Cells(5, Col)).Select
End Sub

regards, Mika


"Bob J." wrote in message
...
Does anybody know what the marco command(s) are for
selecting a range of cells in a column using a variable?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default Selecting a Range Using a Variable

Bob,

If its the row, its easy

Range("A" & startRow & ":B" & endRow).Select

Columns are just as easy if your variable is a letter, but if it is a
number, you either
convert to a letter
Range("A1:" & Chr(startcol + 64) & "10").Select
or use Cells
Range("A1", Cells(10, startcol)).Select

--

HTH

Bob Phillips

"Bob J." wrote in message
...
Does anybody know what the marco command(s) are for
selecting a range of cells in a column using a variable?



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Selecting a Range Using a Variable

Thanks! This is exactly what I was looking for.


-----Original Message-----
yes, hope this example helps:

Sub SelectRows2To5InCol()
Dim Col
Col = 3
Range(Cells(2, Col), Cells(5, Col)).Select
End Sub

regards, Mika


"Bob J." wrote in message
...
Does anybody know what the marco command(s) are for
selecting a range of cells in a column using a

variable?


.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Selecting a Range Using a Variable

Thanks! This is exactly what I was looking for.


-----Original Message-----
Range(Cells(TopLeftRow,TopLeftColumn),Cells

(BottomRightRow,BottomRightColumn
)).Select



Note that you don't need to 'select' a range to use it..
With
Range(Cells(TopLeftRow,TopLeftColumn),Cells

(BottomRightRow,BottomRightColumn
))
.Clear
.Interior.Colorindex=3
End With

--
Patrick Molloy
Microsoft Excel MVP
----------------------------------
"Bob J." wrote in message
...
Does anybody know what the marco command(s) are for
selecting a range of cells in a column using a

variable?


.

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
Find a single value from tables by selecting two variable inputs? jj023 Excel Worksheet Functions 8 February 17th 10 01:40 AM
Selecting a variable print area in a macro Surrealest Excel Discussion (Misc queries) 2 June 7th 09 07:08 AM
macro syntax for selecting variable range Matt Excel Discussion (Misc queries) 1 October 31st 07 07:13 PM
Selecting Variable Data Ranges rc Excel Discussion (Misc queries) 2 May 18th 07 08:26 PM
Selecting rows with variable Jim[_24_] Excel Programming 7 September 16th 03 02:03 PM


All times are GMT +1. The time now is 07:34 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"