Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Select upto last available Row

Hi

I am using below function to select fix range, how can I change "100" with a
variable, so it select from "A2" upto last row which have entry.

Range("A2:AN100").Select

Regards
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Select upto last available Row

Assuming you mean the last row in Column A thru N with a formula or constant
value in it...

LastRow = Range("A:AN").Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlFormulas).Row
Range("A2:AN" & LastRow).Select

Change the xlFormulas to xlValues if you want have only constant values in
your cells or, if there are formulas in them, if you want to ignore formulas
that evaluate to the empty string ("").

--
Rick (MVP - Excel)


"Atif" wrote in message
...
Hi

I am using below function to select fix range, how can I change "100" with
a
variable, so it select from "A2" upto last row which have entry.

Range("A2:AN100").Select

Regards


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Select upto last available Row

Dim myRange as Excel.Range
Dim aWS as Excel.Worksheet
Dim lRow as long

Set aWS = ActiveSheet
Set myRange = aWS.Range("A2")
lRow = aWS.Cells(aWS.Rows.Count,myRange.column).end(xlup) .row

Set myRange = myRange.resize(lrow - myrange.row + 1, 1)
myRange.Select

HTH,
Barb Reinhardt

"Atif" wrote:

Hi

I am using below function to select fix range, how can I change "100" with a
variable, so it select from "A2" upto last row which have entry.

Range("A2:AN100").Select

Regards

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
To execute a formula upto in a cell pol Excel Discussion (Misc queries) 3 August 22nd 08 07:24 AM
adding cells upto and including a specified cell Colin[_3_] Excel Discussion (Misc queries) 6 May 22nd 08 08:51 AM
Convert a number upto 100 to binary Mark Dullingham Excel Programming 7 February 27th 07 02:39 AM
formula to round up any number less than 35 upto 35. Bro40dz Excel Discussion (Misc queries) 5 October 26th 06 07:57 PM
cell with highest value g5 would be upto 80=1,81:160=1.5, [email protected] uk Excel Programming 1 June 13th 06 07:32 PM


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