What does these two statements mean?

Phoenix_Turn

New Member
Joined
May 11, 2011
Messages
37
Hi all,

I am a newbie with computing and was wondering wat does these two statements in vba mean?:

intItem = shtProd.Range("F65336").End(xlUp).Row
intRow = shtStatement.Range("A65336").End(xlUp).Row + 1

where the left handside are integeres

and shtProd and shtStatement are worksheets.

Anyone care to explain?

Thanks
 
It is the equivalent of pressing CTRL + Up Arrow.

So this

intItem = shtProd.Range("F65336").End(xlUp).Row

says from the bottom of column F look up till you find a non blank cell. Then .Row gives the row number.

You should actually write

intItem = shtProd.Range("F" & Rows.Count).End(xlUp).Row

as there could be more than 65,536 filled rows in Excel 2007 and later.
 
Upvote 0

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
It is the equivalent of pressing CTRL + Up Arrow.

So this

intItem = shtProd.Range("F65336").End(xlUp).Row

says from the bottom of column F look up till you find a non blank cell. Then .Row gives the row number.

You should actually write

intItem = shtProd.Range("F" & Rows.Count).End(xlUp).Row

as there could be more than 65,536 filled rows in Excel 2007 and later.

Thanks VoG!

So whats with the number? : 65,536? :S
 
Upvote 0
65,536 is the maximum number of rows in Excel 2003 and earlier. So it looks up from the bottom possible row to find a filled cell.

using the Rows.Count notation makes this more obvious and is independent of the Excel version.
 
Upvote 0
65,536 is the maximum number of rows in Excel 2003 and earlier. So it looks up from the bottom possible row to find a filled cell.

using the Rows.Count notation makes this more obvious and is independent of the Excel version.


Thanks!!! :)

Btw theres no other way to rewrite/restructure the "sentence" to exclude end(xlup)?
 
Last edited:
Upvote 0
That is the bottommost available row. To see run

Code:
Sub Atest()
Range("F" & Rows.Count).Select
End Sub
 
Upvote 0
F is your column letter

Rows.Count is determining what the last row number is (i.e. the total number of rows the current sheet has)

F & Rows.Count is providing a cell reference

If you had ("A" & 1) it would be referencing cell A1
 
Upvote 0
No, it selects the absolute bottom row, empty or filled. You can't go any lower than that.
 
Upvote 0

Forum statistics

Threads
1,224,597
Messages
6,179,808
Members
452,944
Latest member
2558216095

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top