Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default How do I select this range using code....another try at it.

I have four columns that represent the various parts of a road name. The
respective headers are, in order, Prefix, RdName, Suffix and PostDir.

The headers occupy cells A1 through D1.

A user will copy relevant data into this sheet, with cell A2 being the first
cell that could potentially contain data. Most often cell A2 will NOT
contain a value.

It is likely that one of the four columns will contain no data at all
(except for the header).

It is equally likely that there will be sections where there is no data at
all for several rows in a row.

What I need to do:

I need to be able to select the range from cell A2 to E? where the ?
represents the last row number that contains a value.

John Wilson and Per Erik both offered advice in a previous post, but neither
method worked.

TIA.

-gk-


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default How do I select this range using code....another try at it.

Maybe this will help ... though by starting a new thread we don't get to see
what you've already been offered as potential solutions.

Sub LastRow_AtoD()
Dim LastRow As Long
LastRow = Application.WorksheetFunction.Max _
(Range("A65536").End(xlUp).Row, _
Range("B65536").End(xlUp).Row, _
Range("C65536").End(xlUp).Row, _
Range("D65536").End(xlUp).Row)
Range("A1:E" & LastRow).Select
MsgBox LastRow
End Sub

Regards

Trevor


"TBA" wrote in message
...
I have four columns that represent the various parts of a road name. The
respective headers are, in order, Prefix, RdName, Suffix and PostDir.

The headers occupy cells A1 through D1.

A user will copy relevant data into this sheet, with cell A2 being the

first
cell that could potentially contain data. Most often cell A2 will NOT
contain a value.

It is likely that one of the four columns will contain no data at all
(except for the header).

It is equally likely that there will be sections where there is no data at
all for several rows in a row.

What I need to do:

I need to be able to select the range from cell A2 to E? where the ?
represents the last row number that contains a value.

John Wilson and Per Erik both offered advice in a previous post, but

neither
method worked.

TIA.

-gk-




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How do I select this range using code....another try at it.

The only way i know of to do it and be absolutely sure that it i
correct



Sub Macro1()
Dim i As Integer
Dim r As Long
Dim t As Long
For i = 1 To 5 Step 1
t = Cells(65536, i).End(xlUp).Row
If t r Then
r = t
End If
Next i
If r 1 Then
Range("a2:e" & r).Select
End If
End Sub


you could also use

If rows have nbeen deleted from the bottom of you sheet this wil
include those deleted rows in the row so you could end up with severa
blank rows at the bottom selected

sub Macro2
dim r as long
r=Range("a1").SpecialCells(xlLastCell).Row
range("a2:e" & r).select)
end sub

If rows have nbeen deleted from the bottom of you sheet this wil
include those deleted rows in the row so you could end up with severa
blank rows at the bottom selecte

--
Message posted from http://www.ExcelForum.com

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
CODE 2 SELECT SHEETS LISTED IN A RANGE Faraz A. Qureshi Excel Discussion (Misc queries) 1 July 30th 09 07:31 AM
How can change range to select active rows instead of :=Range("S10 ldiaz Excel Discussion (Misc queries) 7 August 29th 08 03:52 PM
Code to select range Shawn Excel Discussion (Misc queries) 1 June 2nd 05 05:14 PM
How do I select this range using code? TBA[_3_] Excel Programming 2 January 14th 04 09:28 PM
CODE to select range based on User Input or Value of Input Field Sandi Gauthier Excel Programming 4 December 8th 03 03:22 PM


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