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
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
intItem is a variable which will hold the last filled cell in column F

and

intRow is a variable which will hold the last unfilled cell in column A just below the last filled cell.

Right on the other parts about worksheets
 
Upvote 0
intItem is a variable which will hold the last filled cell in column F

and

intRow is a variable which will hold the last unfilled cell in column A just below the last filled cell.

Right on the other parts about worksheets

thanks! but what function do they perform? Do they select the last cell or something?
 
Upvote 0
Well we really need to see the full code to know exactly what they are doing, but, typically they are used for retuning a number which normally represents the last cell in a row.

For instance, you want to paste a formula all the way down column B to the end of column A.

The variable returns the last filled cell in column A and uses that variable to fill column B down to the end.

It would look like this as an example

Code:
Range("B" & intItem)
 
Upvote 0
Thanks!

Its pretty long so i decided to paste a pic

1.png

2.png


Oh and what does xlup mean as well? Thanks!
 
Last edited:
Upvote 0
Is this all the code...if so, it doesn't appear that long so if you could next time paste the code itself wrapped in [ code ] 'code here [ / tags ].

Makes it much easier to see

Looks like your variables are searching for the last row and then the variable is used in the loop.

However long the last row is in the column, the loop will run that many times.

In your case it starts at 2 (probably because row 1 is a header) and then loop until in gets to the last row in column F.

A variable can be called anything you want, but the one caution, do not use any type of keywords. I don't know of a place to find these words, but overtime you'll understand what not to use.

In the example below you would not want to use the word Long as a variable name; however, you could write it as intLong and this would be fine.

Basically something that helps you know what you are doing.

http://en.wikipedia.org/wiki/Leszynski_naming_convention

or google

hungarian notation

Code:
Sub FindLastRow()
    Dim LR As Long
    Dim i As Long
    LR = Range("A" & Rows.Count).End(xlUp).Row
    For i = 2 To LR 'if LR is 10 then the loop will run 10X
        'Do something here
    Next i
End Sub

Do this, put a couple of letters in A1:A3. Select A1 then Ctrl + Shift + Down arrow once which will select down to A3 then once again which will now go to the bottom of the spreadsheet. Now press Ctrl + Shift + Up arrow and it will take you back to A3.

This in essence is what xlup is doing.
 
Last edited:
Upvote 0
Thanks for your reply.

Thanks for the links btw!

If it is not too much trouble though can u break their function down and their procedure by each "paragraph"?

Like for example what function is performed in the line:

if dtDay >= dtStart AND dtDay =< dtEnd Then:

to the pasting of the act. sheet

Thanks i really appreciate it!!!
 
Upvote 0
Yes I can do this, but first can you paste the code using code tags so I can cut and paste.

Also, stepping out the door right now, but will be back later.
 
Upvote 0

Forum statistics

Threads
1,224,595
Messages
6,179,798
Members
452,943
Latest member
Newbie4296

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