PDA

View Full Version : Solved: Lastrow +



Klartigue
08-07-2012, 12:36 PM
I am trying to add stuff after the last row. Please see the attached spreadsheet. I would like to add the word "MERRILL" in column c, cell lastrow+3, the word "Fidelity" in column C, cell lastrow+5, and the word "TOTAL" in column C, cell lastrow + 7. Can you help with this??

Paleo
08-07-2012, 12:55 PM
Klartigue,

you can use this:
Sub AddText()
Dim mRow As Long
mRow = Cells(1048576, 3).End(xlUp).Row
Cells(mRow + 3, 3).Value = "MERRILL"
Cells(mRow + 5, 3).Value = "FIDELITY"
Cells(mRow + 7, 3).Value = "TOTAL"
End Sub

Klartigue
08-07-2012, 01:08 PM
That said there was an error with mrow but I used this VBA and it works:

Sub Merrill()
Dim lastrow As Long
Dim i As Long

With ActiveSheet

lastrow = .Cells(.Rows.Count, "C").End(xlUp).Row + 2
.Cells(lastrow + 1, 8).Value = "MERRILL LYNCH"

End With
End Sub
Sub Fidelity()
Dim lastrow As Long
Dim i As Long

With ActiveSheet
lastrow = .Cells(.Rows.Count, "C").End(xlUp).Row + 3

.Cells(lastrow + 1, 8).Value = "FIDELITY"
End With
End Sub
Sub Total()
Dim lastrow As Long
Dim i As Long

With ActiveSheet
lastrow = .Cells(.Rows.Count, "C").End(xlUp).Row + 4

.Cells(lastrow + 1, 8).Value = "TOTAL"
End With
End Sub

Thanks for your help!

Bob Phillips
08-07-2012, 03:00 PM
Why is it in separate subs?