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!
 

Some videos you may like

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Try

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

Jonmo1

MrExcel MVP
Joined
Oct 12, 2006
Messages
44,061
Welcome to the board..

Try

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

Hope this helps.
 

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650

ADVERTISEMENT

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 :)
 

Justin.B

New Member
Joined
Jul 1, 2008
Messages
30
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 )
 

beginner-excel

New Member
Joined
Jun 30, 2008
Messages
36
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 :)
 

beginner-excel

New Member
Joined
Jun 30, 2008
Messages
36
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 )
 

Watch MrExcel Video

Forum statistics

Threads
1,123,053
Messages
5,599,524
Members
414,315
Latest member
Yolanda5050

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
Top