Store Value to use later in the code

  • Thread starter Thread starter Tempy
  • Start date Start date
T

Tempy

Hi,

I no that this is probably very simple, but i need some help with it.
I have a piece of code that finds the last row used and gives the number
of rows in a msg box.
I however want to use this number of rows further on in the code. I
think i have to then store it as a variable. I have tried but to no
avial?! Please help.

I have to put formulas at the bottom of some of these columns and can
use this figure that is found, as the spreadsheet is continually
changing in lenght.

The code from Ron de bruyn is:-
myRows = last
On Error Resume Next
last = ActiveSheet.Cells.Find(What:="", _
After:=[A1], _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
On Error GoTo 0
msgBox last

Les Stout
 
You already put it in a variable, the variable last


in the same procedure you can do

cells(last + 1,"B").Formula = "=Sum(B1:B" & last & ")"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top