Need macro: Go to last row of data

beginner-excel

New Member
Joined
Jun 30, 2008
Messages
36
Hi everyone,

Newbie here and I searched for an answer on this forum but maybe I don't have the correct syntax.

I need a macro to go to the last row of data and insert data "123" in the row after the last row (the column will be Column A).

The only problem is, there are blank cells between some rows. I need to go to the absolute last row of data.

Help!
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Try

Code:
Sub test()
Dim LR As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
Range("A" & LR + 1).Value = 123
End Sub
 
Upvote 0
Welcome to the board..

Try

Cells(Rows.Count,"A").End(xlup).Offset(1,0).Value = "123"

Hope this helps.
 
Upvote 0
Like this

Code:
Sub test()
Dim LR As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
With Range("A" & LR + 1)
    .Value = 123
    With .Font
        .Name = "Arial"
        .Size = 10
        .ColorIndex = 3
    End With
End With
End Sub

Hint: You can use the macro recorder to get the syntax for formatting and so on :)
 
Upvote 0
If using as part of a form for VBA try this code out.

Code:
Nextrow = Worksheets("Worksheet to put data to").Range("A65536").End(xlUp).Row + 1
Worksheets("Worksheet to put data to").Cells(Nextrow, 1).Resize(1, 7).Value = Array( _
value 1, _
value 2 )
 
Upvote 0
Thank you so much! =)

Like this

Code:
Sub test()
Dim LR As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
With Range("A" & LR + 1)
    .Value = 123
    With .Font
        .Name = "Arial"
        .Size = 10
        .ColorIndex = 3
    End With
End With
End Sub
Hint: You can use the macro recorder to get the syntax for formatting and so on :)
 
Upvote 0
Thank you too! =)
If using as part of a form for VBA try this code out.

Code:
Nextrow = Worksheets("Worksheet to put data to").Range("A65536").End(xlUp).Row + 1
Worksheets("Worksheet to put data to").Cells(Nextrow, 1).Resize(1, 7).Value = Array( _
value 1, _
value 2 )
 
Upvote 0

Forum statistics

Threads
1,214,583
Messages
6,120,378
Members
448,955
Latest member
BatCoder

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