Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Help Finding the Final Row

I need to set a variable equal to my final row that
contains data. I have a function, but it only checks for
the final row that contains data in column A. My final
row sometimes doesn't contain data in column A, but it
will always be in column A or column B. This is what I
have. Thanks for the help. I need it to give the number
of the last row containing data in column A or column B/

FinalRow = Cells(65536, 1).End(xlUp).Row
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Help Finding the Final Row

You can use this example that use a function

Sub test()
MsgBox LastRow(ActiveSheet)
End Sub

Function LastRow(sh As Worksheet)
On Error Resume Next
LastRow = sh.Cells.Find(What:="*", _
After:=sh.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
On Error GoTo 0
End Function



--
Regards Ron de Bruin
http://www.rondebruin.nl


wrote in message ...
I need to set a variable equal to my final row that
contains data. I have a function, but it only checks for
the final row that contains data in column A. My final
row sometimes doesn't contain data in column A, but it
will always be in column A or column B. This is what I
have. Thanks for the help. I need it to give the number
of the last row containing data in column A or column B/

FinalRow = Cells(65536, 1).End(xlUp).Row



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Help Finding the Final Row

I use this:

lastrow = ActiveSheet.UsedRange.Rows.Count

Likewise, you can use the following to find the last
column:

lastcolumn = ActiveSheet.UsedRange.Columns.Count

Keep in mind that if there are formats in cells that it
will count those as well, so this may or may not be
exactly what you need if you just want the last row with
data.

-----Original Message-----
I need to set a variable equal to my final row that
contains data. I have a function, but it only checks

for
the final row that contains data in column A. My final
row sometimes doesn't contain data in column A, but it
will always be in column A or column B. This is what I
have. Thanks for the help. I need it to give the

number
of the last row containing data in column A or column B/

FinalRow = Cells(65536, 1).End(xlUp).Row
.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Help Finding the Final Row

FinalRowA = Cells(Rows.Count, "A").End(xlUp).Row
FinalRowB = Cells(Rows.Count, "B").End(xlUp).Row
FinalRow = IIf(FinalRowA FinalRowB, FinalRowA, FinalRowB)

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

wrote in message
...
I need to set a variable equal to my final row that
contains data. I have a function, but it only checks for
the final row that contains data in column A. My final
row sometimes doesn't contain data in column A, but it
will always be in column A or column B. This is what I
have. Thanks for the help. I need it to give the number
of the last row containing data in column A or column B/

FinalRow = Cells(65536, 1).End(xlUp).Row



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
final return! via135 Excel Worksheet Functions 5 January 11th 08 11:00 AM
Final day of month B Excel Worksheet Functions 3 July 25th 07 12:49 AM
My Final #DIV/0! that I'd like to say Goodbye to! Dan the Man[_2_] Excel Worksheet Functions 20 July 23rd 07 05:40 PM
Help for final touch up to my code Bimal[_3_] Excel Programming 3 February 5th 04 11:20 AM
Need final code tweak Phil Hageman Excel Programming 12 August 16th 03 08:53 PM


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