Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default return row number

Hi,

How can I return the row number (in VB inside a macro) of the last
data-containing cell in a particular column?


Thanks for any help,

Jon


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default return row number

Jon,

Try something like the following:

Dim RowNum As Long
RowNum = Cells(Rows.Count,"A").End(xlUp).Row

Change the "A" to the column of interest.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Jonathan Vickers" wrote in message
...
Hi,

How can I return the row number (in VB inside a macro) of the

last
data-containing cell in a particular column?


Thanks for any help,

Jon




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default return row number

Thanks for the help, Chip.

I want to use the result in the next part of the code in place of the 400:

Rows("6:400").Sort ..............

but it doesn't seem to work.

Is there something else that I need to do, or should I be approaching this
in another way?

Thanks once again for any help,

Jon


"Chip Pearson" wrote in message
...
Jon,

Try something like the following:

Dim RowNum As Long
RowNum = Cells(Rows.Count,"A").End(xlUp).Row

Change the "A" to the column of interest.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Jonathan Vickers" wrote in message
...
Hi,

How can I return the row number (in VB inside a macro) of the

last
data-containing cell in a particular column?


Thanks for any help,

Jon






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default return row number

Rows("6:" & rowNum).Sort


demo'd from the immediate window:

rowNum = 600
? Rows("6:" & rowNum).Address
$6:$600

--
Regards,
Tom Ogilvy


"Jonathan Vickers" wrote in message
...
Thanks for the help, Chip.

I want to use the result in the next part of the code in place of the 400:

Rows("6:400").Sort ..............

but it doesn't seem to work.

Is there something else that I need to do, or should I be approaching this
in another way?

Thanks once again for any help,

Jon


"Chip Pearson" wrote in message
...
Jon,

Try something like the following:

Dim RowNum As Long
RowNum = Cells(Rows.Count,"A").End(xlUp).Row

Change the "A" to the column of interest.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Jonathan Vickers" wrote in message
...
Hi,

How can I return the row number (in VB inside a macro) of the

last
data-containing cell in a particular column?


Thanks for any help,

Jon








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
Return Number George Excel Discussion (Misc queries) 2 March 3rd 09 05:49 PM
Return the Row number Kenneth Excel Discussion (Misc queries) 3 November 19th 08 08:45 AM
Return a High Number Anthony Excel Worksheet Functions 6 February 25th 08 03:25 PM
How to format number and not return ###### [email protected] Excel Worksheet Functions 4 September 12th 07 09:35 AM
command to return the row number or cell number in excel? desmondleow[_5_] Excel Programming 1 December 11th 03 10:51 AM


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