Active cell

G

Guest

Hello,

this is my VBA Macro:
I want to select "clastrow" as my active cell. is that possible ?
Thanks,
Sub SumM()
Dim clastrow As Long
Dim olast As Range

clastrow = Cells(Rows.Count, "I").End(xlUp).Row
MsgBox clastrow
Set olast = Range("I" & clastrow)
isum = Application.WorksheetFunction.Sum(Range("I4:I" & olast))
ActiveCell.Value = isum


End Sub
 
B

Bob Phillips

Not quite Jeff,

You get the last row, cLastRow, but then use that cell rather than the row
in the formula. Try

Sub SumM()
Dim clastrow As Long
Dim olast As Range
Dim iSum

clastrow = Cells(Rows.Count, "I").End(xlUp).Row
iSum = Application.WorksheetFunction.Sum(Range("I4:I" & clastrow))
ActiveCell.Value = iSum

End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
B

Bob Phillips

I was in that cell when I tested it :).

I hope you mean last row + 1

Sub SumM()
Dim clastrow As Long
Dim olast As Range
Dim iSum

clastrow = Cells(Rows.Count, "I").End(xlUp).Row
iSum = Application.WorksheetFunction.Sum(Range("I4:I" & clastrow))
Cells(clastrow + 1, "I").Value = iSum

End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)
 

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

Similar Threads


Top