Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default Select range

Hi! I am writing a macro where I want to select a range. the first cell I
want to have in the selection is A1 but the last cell is
Range("a1").offset(i,0). Thus I cannot simple write Range("a1:A3").select.
how shall I write it? pls help!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Select range

Try this

i = Cells(Cells.Rows.Count, "A").End(xlUp).Row

Range("a1:A" & i).Select

Mike

"Arne Hegefors" wrote:

Hi! I am writing a macro where I want to select a range. the first cell I
want to have in the selection is A1 but the last cell is
Range("a1").offset(i,0). Thus I cannot simple write Range("a1:A3").select.
how shall I write it? pls help!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default Select range

thanks. but that does not work for me since A1 is not a fixed cell just an
example. I tried writing:

Range("a1" & Range("a1").Offset(i, 9)).Select

but that did not select the whole area but just the two cells. please please
can someone help me!

"Mike H" skrev:

Try this

i = Cells(Cells.Rows.Count, "A").End(xlUp).Row

Range("a1:A" & i).Select

Mike

"Arne Hegefors" wrote:

Hi! I am writing a macro where I want to select a range. the first cell I
want to have in the selection is A1 but the last cell is
Range("a1").offset(i,0). Thus I cannot simple write Range("a1:A3").select.
how shall I write it? pls help!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Select range

How is the first cell in the range determined

The first populated cell ? Try this

p = Range("A1").End(xlDown).Row
i = Cells(Cells.Rows.Count, "A").End(xlUp).Row
Range("a" & p & ":A" & i).Select


Or in a loop? Try this

For x = 1 To 5
topcell = Range("A1").Offset(x).Row
bottomcell = Cells(Cells.Rows.Count, "A").End(xlUp).Row
Range("A" & topcell & ":A" & bottomcell).Select
Next

Mike

"Arne Hegefors" wrote:

thanks. but that does not work for me since A1 is not a fixed cell just an
example. I tried writing:

Range("a1" & Range("a1").Offset(i, 9)).Select

but that did not select the whole area but just the two cells. please please
can someone help me!

"Mike H" skrev:

Try this

i = Cells(Cells.Rows.Count, "A").End(xlUp).Row

Range("a1:A" & i).Select

Mike

"Arne Hegefors" wrote:

Hi! I am writing a macro where I want to select a range. the first cell I
want to have in the selection is A1 but the last cell is
Range("a1").offset(i,0). Thus I cannot simple write Range("a1:A3").select.
how shall I write it? pls help!

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
How can change range to select active rows instead of :=Range("S10 ldiaz Excel Discussion (Misc queries) 7 August 29th 08 03:52 PM
macro to select range from active cell range name string aelbob Excel Programming 2 July 14th 08 09:19 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
Compare a selected Range with a Named range and select cells that do not exist PCLIVE Excel Programming 1 October 18th 05 07:09 PM
Select Sheet then Select Range Gee[_2_] Excel Programming 3 May 27th 04 10:10 PM


All times are GMT +1. The time now is 01:58 PM.

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

About Us

"It's about Microsoft Excel"