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

Hi, I've been trying to figure out how to use these suggestions, but none of
them work. I've put them as a cell formula, vba and functions but I always
get #value or #name or something. I know this is my error but I'm beyond
frustrated and can't figure out what I'm missing. Can someone please tell me
what I'm doing wrong, and exactly how these would get used?

lastRowNo = Range("A65536").End(xlUp).Row
Range("A2"),End(xlDown).Row if there are no blanks in the data,
otherwise
Cells(Rows.Count,"A").End(xlUp).Row

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 269
Default last row number value question

Tx, I see no reason why lastRowNo = Range("A65536").End(xlUp).Row would
ever give an error in VBA unless you've Dimmed lastRowNo as something
other than a Long. When returning a row value to a variable, the
variable should be Dimmed as a Long. In your
Range("A2").End(xlDown).Row, you've got a comma before End instead of a
period. I see no problem with the last one. These are for VBA, not
for cell formulas. There should be comparable formulas for use in
cells, but I'm not familiar with those. James

TxVics wrote:
Hi, I've been trying to figure out how to use these suggestions, but none of
them work. I've put them as a cell formula, vba and functions but I always
get #value or #name or something. I know this is my error but I'm beyond
frustrated and can't figure out what I'm missing. Can someone please tell me
what I'm doing wrong, and exactly how these would get used?

lastRowNo = Range("A65536").End(xlUp).Row
Range("A2"),End(xlDown).Row if there are no blanks in the data,
otherwise
Cells(Rows.Count,"A").End(xlUp).Row


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default last row number value question

I appreicate the input, but I'm not even that far - if I were to create this
in VBA, exactly how does it get entered? Meaning, what goes before and
after this line? If i put it in with just the exact code below:

lastRowNo = Range("A65536").End(xlUp).Row


Then it still doesn't show up as a function or a macro, it's just text.
What I really need is to see the whole code that goes into VBA. Sorry to be
so basic on this, but I'm kind of winging the scripting thing.

Thank you!




"Zone" wrote:

Tx, I see no reason why lastRowNo = Range("A65536").End(xlUp).Row would
ever give an error in VBA unless you've Dimmed lastRowNo as something
other than a Long. When returning a row value to a variable, the
variable should be Dimmed as a Long. In your
Range("A2").End(xlDown).Row, you've got a comma before End instead of a
period. I see no problem with the last one. These are for VBA, not
for cell formulas. There should be comparable formulas for use in
cells, but I'm not familiar with those. James

TxVics wrote:
Hi, I've been trying to figure out how to use these suggestions, but none of
them work. I've put them as a cell formula, vba and functions but I always
get #value or #name or something. I know this is my error but I'm beyond
frustrated and can't figure out what I'm missing. Can someone please tell me
what I'm doing wrong, and exactly how these would get used?

lastRowNo = Range("A65536").End(xlUp).Row
Range("A2"),End(xlDown).Row if there are no blanks in the data,
otherwise
Cells(Rows.Count,"A").End(xlUp).Row



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 269
Default last row number value question

Tx, If you do not have a module created yet, follow these steps:
1. With the spreadsheet on the screen, press Alt-F11
2. Select Insert from the menubar, then Module.

Copy the code below and paste it into your module (beginning with the
line Sub Test()
and ending with the line End Function).
Then Press Alt-F11 to return to the spreadsheet.

Sub Test()
MsgBox LROW(Range("a65536"))
End Sub

Function LROW(StartRg As Range)
LROW = StartRg.End(xlUp).Row
End Function

This code contains a subroutine and a user-defined function. Functions
return a value, subroutines do not.

To run the subroutine from the spreadsheet, click on Tools on the
menubar, then Macro, then Macros. A box will appear with Test
selected. Click on Run. The Test subroutine will run and "call" the
function, which will return a value to the subroutine and the message
box will display it.

You can also call the function directly from the spreadsheet. In a
blank cell, type this:
=LROW(A65536)
then press the Enter key.
The cell will display the row number of the first cell above cell 65536
that has something in it. You can replace A65536 with any other cell
address. Note that the function will look upward from the cell address
you put in (the function's "argument") until it finds a cell above it
(in the same column) that has something in it. Or, if the cell address
you use has something in it, the function will look upward until it
finds a cell without something in it. If the function doesn't find
what it's looking for, it will go all the way to the top row and return
a 1. Hope this helps you. James

TxVics wrote:
I appreicate the input, but I'm not even that far - if I were to create this
in VBA, exactly how does it get entered? Meaning, what goes before and
after this line? If i put it in with just the exact code below:

lastRowNo = Range("A65536").End(xlUp).Row


Then it still doesn't show up as a function or a macro, it's just text.
What I really need is to see the whole code that goes into VBA. Sorry to be
so basic on this, but I'm kind of winging the scripting thing.

Thank you!




"Zone" wrote:

Tx, I see no reason why lastRowNo = Range("A65536").End(xlUp).Row would
ever give an error in VBA unless you've Dimmed lastRowNo as something
other than a Long. When returning a row value to a variable, the
variable should be Dimmed as a Long. In your
Range("A2").End(xlDown).Row, you've got a comma before End instead of a
period. I see no problem with the last one. These are for VBA, not
for cell formulas. There should be comparable formulas for use in
cells, but I'm not familiar with those. James

TxVics wrote:
Hi, I've been trying to figure out how to use these suggestions, but none of
them work. I've put them as a cell formula, vba and functions but I always
get #value or #name or something. I know this is my error but I'm beyond
frustrated and can't figure out what I'm missing. Can someone please tell me
what I'm doing wrong, and exactly how these would get used?

lastRowNo = Range("A65536").End(xlUp).Row
Range("A2"),End(xlDown).Row if there are no blanks in the data,
otherwise
Cells(Rows.Count,"A").End(xlUp).Row




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default last row number value question

Thank you, thank you, thank you!!! I just couldn't make the connection
between "Function" and the entry in the actual cell. This works perfectly
now, thanks so much for taking the time to break it down for me!



"Zone" wrote:

Tx, If you do not have a module created yet, follow these steps:
1. With the spreadsheet on the screen, press Alt-F11
2. Select Insert from the menubar, then Module.

Copy the code below and paste it into your module (beginning with the
line Sub Test()
and ending with the line End Function).
Then Press Alt-F11 to return to the spreadsheet.

Sub Test()
MsgBox LROW(Range("a65536"))
End Sub

Function LROW(StartRg As Range)
LROW = StartRg.End(xlUp).Row
End Function

This code contains a subroutine and a user-defined function. Functions
return a value, subroutines do not.

To run the subroutine from the spreadsheet, click on Tools on the
menubar, then Macro, then Macros. A box will appear with Test
selected. Click on Run. The Test subroutine will run and "call" the
function, which will return a value to the subroutine and the message
box will display it.

You can also call the function directly from the spreadsheet. In a
blank cell, type this:
=LROW(A65536)
then press the Enter key.
The cell will display the row number of the first cell above cell 65536
that has something in it. You can replace A65536 with any other cell
address. Note that the function will look upward from the cell address
you put in (the function's "argument") until it finds a cell above it
(in the same column) that has something in it. Or, if the cell address
you use has something in it, the function will look upward until it
finds a cell without something in it. If the function doesn't find
what it's looking for, it will go all the way to the top row and return
a 1. Hope this helps you. James

TxVics wrote:
I appreicate the input, but I'm not even that far - if I were to create this
in VBA, exactly how does it get entered? Meaning, what goes before and
after this line? If i put it in with just the exact code below:

lastRowNo = Range("A65536").End(xlUp).Row


Then it still doesn't show up as a function or a macro, it's just text.
What I really need is to see the whole code that goes into VBA. Sorry to be
so basic on this, but I'm kind of winging the scripting thing.

Thank you!




"Zone" wrote:

Tx, I see no reason why lastRowNo = Range("A65536").End(xlUp).Row would
ever give an error in VBA unless you've Dimmed lastRowNo as something
other than a Long. When returning a row value to a variable, the
variable should be Dimmed as a Long. In your
Range("A2").End(xlDown).Row, you've got a comma before End instead of a
period. I see no problem with the last one. These are for VBA, not
for cell formulas. There should be comparable formulas for use in
cells, but I'm not familiar with those. James

TxVics wrote:
Hi, I've been trying to figure out how to use these suggestions, but none of
them work. I've put them as a cell formula, vba and functions but I always
get #value or #name or something. I know this is my error but I'm beyond
frustrated and can't figure out what I'm missing. Can someone please tell me
what I'm doing wrong, and exactly how these would get used?

lastRowNo = Range("A65536").End(xlUp).Row
Range("A2"),End(xlDown).Row if there are no blanks in the data,
otherwise
Cells(Rows.Count,"A").End(xlUp).Row






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 269
Default last row number value question

Tx, It is enjoyable to be able to help someone, and even more fun when
they reply with good news. You might want to check out John
Walkenbach's books such as Excel 2003 Power Programming with VBA. Good
luck! James

TxVics wrote:
Thank you, thank you, thank you!!! I just couldn't make the connection
between "Function" and the entry in the actual cell. This works perfectly
now, thanks so much for taking the time to break it down for me!



"Zone" wrote:

Tx, If you do not have a module created yet, follow these steps:
1. With the spreadsheet on the screen, press Alt-F11
2. Select Insert from the menubar, then Module.

Copy the code below and paste it into your module (beginning with the
line Sub Test()
and ending with the line End Function).
Then Press Alt-F11 to return to the spreadsheet.

Sub Test()
MsgBox LROW(Range("a65536"))
End Sub

Function LROW(StartRg As Range)
LROW = StartRg.End(xlUp).Row
End Function

This code contains a subroutine and a user-defined function. Functions
return a value, subroutines do not.

To run the subroutine from the spreadsheet, click on Tools on the
menubar, then Macro, then Macros. A box will appear with Test
selected. Click on Run. The Test subroutine will run and "call" the
function, which will return a value to the subroutine and the message
box will display it.

You can also call the function directly from the spreadsheet. In a
blank cell, type this:
=LROW(A65536)
then press the Enter key.
The cell will display the row number of the first cell above cell 65536
that has something in it. You can replace A65536 with any other cell
address. Note that the function will look upward from the cell address
you put in (the function's "argument") until it finds a cell above it
(in the same column) that has something in it. Or, if the cell address
you use has something in it, the function will look upward until it
finds a cell without something in it. If the function doesn't find
what it's looking for, it will go all the way to the top row and return
a 1. Hope this helps you. James

TxVics wrote:
I appreicate the input, but I'm not even that far - if I were to create this
in VBA, exactly how does it get entered? Meaning, what goes before and
after this line? If i put it in with just the exact code below:

lastRowNo = Range("A65536").End(xlUp).Row


Then it still doesn't show up as a function or a macro, it's just text.
What I really need is to see the whole code that goes into VBA. Sorry to be
so basic on this, but I'm kind of winging the scripting thing.

Thank you!




"Zone" wrote:

Tx, I see no reason why lastRowNo = Range("A65536").End(xlUp).Row would
ever give an error in VBA unless you've Dimmed lastRowNo as something
other than a Long. When returning a row value to a variable, the
variable should be Dimmed as a Long. In your
Range("A2").End(xlDown).Row, you've got a comma before End instead of a
period. I see no problem with the last one. These are for VBA, not
for cell formulas. There should be comparable formulas for use in
cells, but I'm not familiar with those. James

TxVics wrote:
Hi, I've been trying to figure out how to use these suggestions, but none of
them work. I've put them as a cell formula, vba and functions but I always
get #value or #name or something. I know this is my error but I'm beyond
frustrated and can't figure out what I'm missing. Can someone please tell me
what I'm doing wrong, and exactly how these would get used?

lastRowNo = Range("A65536").End(xlUp).Row
Range("A2"),End(xlDown).Row if there are no blanks in the data,
otherwise
Cells(Rows.Count,"A").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
Large Number Question Mangler Excel Worksheet Functions 3 December 18th 08 02:01 PM
Number Question Rebecca New Users to Excel 4 February 28th 08 11:57 AM
MS Excel number question Redsphynx Excel Discussion (Misc queries) 2 February 7th 08 01:06 AM
Number formatting question Robbie in Houston Excel Worksheet Functions 8 March 15th 05 03:19 PM
Question number Two Robert Couchman[_4_] Excel Programming 1 February 19th 04 11:54 AM


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