a command button to insert an object into the next blank cell incolumn E

J

jp

Hi all,
I apperciate any help I can get. I would like to create a command
button that when pushed will insert an object into the next blank cell
on column E. I can record a macro to insert the object (actually an
icon link to the object) but cant figure out how to get it to
automatically insert it into the next blank cell in the column. any
suggestions for code to insert into the recorded macro.
Thank you.....
 
J

JLGWhiz

Assuming you mean the next blank row at the bottom of a specific column, and
using column A as the example. If you are using a command button from the
forms toolbar just remove the Private Sub CommandButton1_Click and replace it
with Sub <your title>. Also, the Click event code goes behind the command
button by right click on button>view code and paste. The other version will
go into the standard code module1.

Version for Ctrl Tlbx Btn:

Private Sub CommandButton1_Click()
Dim lr As Long
lr = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
Selection.Copy Range("A" & lr)
End Sub

Version for forms cmd btn:

Sub <your title>()
Dim lr As Long
lr = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
Selection.Copy Range("A" & lr)
End Sub
 
J

JLGWhiz

Must be too late at night. Use these corrected versions.

Version for Ctrl Tlbx Btn:

Private Sub CommandButton1_Click()
Dim lr As Long
lr = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
Selection.Copy Range("A" & lr + 1)
End Sub

Version for forms cmd btn:

Sub <your title>()
Dim lr As Long
lr = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
Selection.Copy Range("A" & lr + 1)
End Sub
 

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

Top