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

Hi,

I have a named range "Amount_Local" in a single column.

The following line of code will find the last cell before a blank cell,
which is what I want.
Range("Amount_Local").End(xlDown).Select

How can I get it to tell me what row it is?

thanks,
Harold


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default returning a row number

To answer your direct question, Selection.Row should give you that, as in
this example...

Range("Amount_Local").End(xlDown).Select
MsgBox Selection.Row

HOWEVER, you almost never have to select a cell in order to work with it in
VB. You can get the row directly like this...

MsgBox Range("Amount_Local").End(xlDown).Row

If you have more than one thing to do to the cell, use a With/EndWith
block...

With Range("Amount_Local").End(xlDown)
.Value = "New Text In The Cell"
.Font.Size = 18
.Font.ColorIndex = 3
End With

--
Rick (MVP - Excel)


"Harold Good" wrote in message
...
Hi,

I have a named range "Amount_Local" in a single column.

The following line of code will find the last cell before a blank cell,
which is what I want.
Range("Amount_Local").End(xlDown).Select

How can I get it to tell me what row it is?

thanks,
Harold


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default returning a row number

msgbox Range("Amount_Local").End(xlDown).row
--
HTH...

Jim Thomlinson


"Harold Good" wrote:

Hi,

I have a named range "Amount_Local" in a single column.

The following line of code will find the last cell before a blank cell,
which is what I want.
Range("Amount_Local").End(xlDown).Select

How can I get it to tell me what row it is?

thanks,
Harold



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default returning a row number

Thanks, I realize I was not clear in my description. I don't need a message
box to tell me. I should have said how can it RETURN the value of that row
so I can use it to select a bigger range for sorting.

Thanks again,
Harold


"Rick Rothstein" wrote in message
...
To answer your direct question, Selection.Row should give you that, as in
this example...

Range("Amount_Local").End(xlDown).Select
MsgBox Selection.Row

HOWEVER, you almost never have to select a cell in order to work with it
in VB. You can get the row directly like this...

MsgBox Range("Amount_Local").End(xlDown).Row

If you have more than one thing to do to the cell, use a With/EndWith
block...

With Range("Amount_Local").End(xlDown)
.Value = "New Text In The Cell"
.Font.Size = 18
.Font.ColorIndex = 3
End With

--
Rick (MVP - Excel)


"Harold Good" wrote in message
...
Hi,

I have a named range "Amount_Local" in a single column.

The following line of code will find the last cell before a blank cell,
which is what I want.
Range("Amount_Local").End(xlDown).Select

How can I get it to tell me what row it is?

thanks,
Harold




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default returning a row number

If that is still a question, just assign it to your variable instead of
MessageBox'ing it...

YourVariable = Range("Amount_Local").End(xlDown).Row

--
Rick (MVP - Excel)


"Harold Good" wrote in message
...
Thanks, I realize I was not clear in my description. I don't need a
message box to tell me. I should have said how can it RETURN the value of
that row so I can use it to select a bigger range for sorting.

Thanks again,
Harold


"Rick Rothstein" wrote in message
...
To answer your direct question, Selection.Row should give you that, as in
this example...

Range("Amount_Local").End(xlDown).Select
MsgBox Selection.Row

HOWEVER, you almost never have to select a cell in order to work with it
in VB. You can get the row directly like this...

MsgBox Range("Amount_Local").End(xlDown).Row

If you have more than one thing to do to the cell, use a With/EndWith
block...

With Range("Amount_Local").End(xlDown)
.Value = "New Text In The Cell"
.Font.Size = 18
.Font.ColorIndex = 3
End With

--
Rick (MVP - Excel)


"Harold Good" wrote in message
...
Hi,

I have a named range "Amount_Local" in a single column.

The following line of code will find the last cell before a blank cell,
which is what I want.
Range("Amount_Local").End(xlDown).Select

How can I get it to tell me what row it is?

thanks,
Harold







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default returning a row number

Ahh, I see that something like this seems to do the trick:
RangeFinish = Range("Amount_Local").End(xlDown).Row

Thanks very much Rick and Jim for your help,
Harold


"Harold Good" wrote in message
...
Thanks, I realize I was not clear in my description. I don't need a
message box to tell me. I should have said how can it RETURN the value of
that row so I can use it to select a bigger range for sorting.

Thanks again,
Harold


"Rick Rothstein" wrote in message
...
To answer your direct question, Selection.Row should give you that, as in
this example...

Range("Amount_Local").End(xlDown).Select
MsgBox Selection.Row

HOWEVER, you almost never have to select a cell in order to work with it
in VB. You can get the row directly like this...

MsgBox Range("Amount_Local").End(xlDown).Row

If you have more than one thing to do to the cell, use a With/EndWith
block...

With Range("Amount_Local").End(xlDown)
.Value = "New Text In The Cell"
.Font.Size = 18
.Font.ColorIndex = 3
End With

--
Rick (MVP - Excel)


"Harold Good" wrote in message
...
Hi,

I have a named range "Amount_Local" in a single column.

The following line of code will find the last cell before a blank cell,
which is what I want.
Range("Amount_Local").End(xlDown).Select

How can I get it to tell me what row it is?

thanks,
Harold






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
Returning a column name or number Frank[_4_] Excel Worksheet Functions 5 July 1st 07 05:58 AM
Searching and returning row number of a value MikeDH Excel Worksheet Functions 1 August 9th 05 06:06 PM
Returning a value for a number in a range Derek Excel Discussion (Misc queries) 1 July 26th 05 04:47 PM
Returning The Column Number ? MAS Excel Programming 2 July 21st 04 09:06 PM
returning max UsedRange row number drabbacs Excel Programming 4 February 16th 04 07:59 PM


All times are GMT +1. The time now is 11:18 AM.

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"