Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default How to select range of cells

I need to write a macro which selects a range of cells based on given
variables.

Example:

A2 = 3 '(1st column to be selected)
B2 = 58 '(Last column to be selected)
C2 = 10 '(10 rows to be selected)
D2 = F3 '( Start Selection @ F3 )

A = Range ("A2")
B = Range ("B2")
C = Range ("C2")

How to replace this line with one containing the above variables to produce
this result:
Range ("F3:BJ58").select

I can deal with the numbers, but the column names are giving me problems

It should look something like this
Range ("F3"). Select
Range ("F" & A & ":???" & B - A).select

Thanks for your help

Jan


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default How to select range of cells

One way:

A = Range("A2").Value
B = Range("B2").Value
C = Range("C2").Value

Range(Range("D2").Value).Resize(C, B - A + 1).Select




In article ,
"Jan Nademlejnsky" wrote:

I need to write a macro which selects a range of cells based on given
variables.

Example:

A2 = 3 '(1st column to be selected)
B2 = 58 '(Last column to be selected)
C2 = 10 '(10 rows to be selected)
D2 = F3 '( Start Selection @ F3 )

A = Range ("A2")
B = Range ("B2")
C = Range ("C2")

How to replace this line with one containing the above variables to produce
this result:
Range ("F3:BJ58").select

I can deal with the numbers, but the column names are giving me problems

It should look something like this
Range ("F3"). Select
Range ("F" & A & ":???" & B - A).select

Thanks for your help

Jan

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default How to select range of cells

Thank you very much. This is exactly what I was after.

Jan

"JE McGimpsey" wrote in message
...
One way:

A = Range("A2").Value
B = Range("B2").Value
C = Range("C2").Value

Range(Range("D2").Value).Resize(C, B - A + 1).Select




In article ,
"Jan Nademlejnsky" wrote:

I need to write a macro which selects a range of cells based on given
variables.

Example:

A2 = 3 '(1st column to be selected)
B2 = 58 '(Last column to be selected)
C2 = 10 '(10 rows to be selected)
D2 = F3 '( Start Selection @ F3 )

A = Range ("A2")
B = Range ("B2")
C = Range ("C2")

How to replace this line with one containing the above variables to
produce
this result:
Range ("F3:BJ58").select

I can deal with the numbers, but the column names are giving me problems

It should look something like this
Range ("F3"). Select
Range ("F" & A & ":???" & B - A).select

Thanks for your help

Jan



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
Select a range of cells wx4usa Excel Discussion (Misc queries) 2 December 23rd 09 07:32 PM
When entering data into a range of cells, select the entire range. Q Excel Discussion (Misc queries) 0 September 26th 07 04:36 AM
Select Range of Cells programmingrookie Excel Discussion (Misc queries) 2 August 11th 05 07:13 PM
select from a range only some cells hulub[_4_] Excel Programming 0 September 21st 04 04:29 PM
select from a range only some cells hulub[_3_] Excel Programming 1 September 21st 04 03:14 PM


All times are GMT +1. The time now is 02:01 AM.

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"