VBA to repeat a task within a worksheet by clicking macro button

zumanzi_011

New Member
Joined
Jun 16, 2015
Messages
10
Hello,

Say, I have cells to fill out First name, Surname and DOB for one person, now I want to add info for 2 more persons, how can I do that by clicking a button (of course twice) and those fields will show up underneath the first person's info cells.

Please note that my Macro knowledge is pretty basic.

Thanks.
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Are you trying to put "First name, Surname and DOB " all in the same cell?
 
Upvote 0
Just to add to the main question, I was able to create a macro and a button for it whereby I recorded macro say copy cells (A1 to B6) and paste within (A11 to B16). Now the problem is when I click the button again, it copy pastes to the same location i.e. (A11 to B16) whereby I want those to be copied 2-3 cells below the latest copied cells.
 
Upvote 0
What cells do you want them in?
Would it be:
Column A First Name
Column B SurName
Column C DOB

It's always better to spell out details.
 
Upvote 0
Try this:
Code:
Sub Names()
Application.ScreenUpdating = False
Cells(Rows.Count, "A").End(xlUp).Offset(-([A1] <> "")) = InputBox("First Name?")
Cells(Rows.Count, "B").End(xlUp).Offset(-([B1] <> "")) = InputBox("SurName?")
Cells(Rows.Count, "C").End(xlUp).Offset(-([C1] <> "")) = InputBox("DOB?")
Application.ScreenUpdating = True
End Sub
 
Upvote 0
The list is longer. But just to save your time I am giving you a shorter version
What I have right now:

Cell A1 "First Name" Cell B1"blank to fill out"
Cell A2 "Last Name" Cell B2"blank to fill out"
Cell A3 "DOB" Cell B3"blank to fill out"

What I want just by clicking a macro button

Cell A5 "First Name" Cell B5"blank to fill out"
Cell A6 "Last Name" Cell B6"blank to fill out"
Cell A7 "DOB" Cell B7"blank to fill out"

and I would like to add more such cells (i.e. personnel info) below these just by clicking that button.

As I mentioned in my comment above, I recorded a macro which copy pastes, but problem is its copy pasting In the same cells, not moving below.

Hope that makes sense.

Appreciate your support.
 
Upvote 0
OK try this:
Code:
Sub Names()
Application.ScreenUpdating = False
Cells(Rows.Count, "A").End(xlUp).Offset(-([A1] <> "")) = InputBox("First Name?")
Cells(Rows.Count, "A").End(xlUp).Offset(-([A1] <> "")) = InputBox("SurName?")
Cells(Rows.Count, "A").End(xlUp).Offset(-([A1] <> "")) = InputBox("DOB?")
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Thanks for the code.

This is nice but I want in a different way. Please see below example with column A should be pre filled and column B empty


First Name John

Surname Beare

Date arrived on-board/site 03/05/2015

Job title 1. Roustabout (Lease hand)

Nationality Albanian

Employer Client

Involved as Witness

Comments Nothing further



So, what I want is to create macro button that would enable me to add another set of similar cells (say A1 to B8) below the existing cells.
 
Upvote 0
Sorry, I don't want to sound stubborn here, but I don't want prompt window. I just want the macro to duplicate the cells underneath the existing ones as mentioned from previous comment.

Again thanks a lot for your time.
 
Upvote 0

Forum statistics

Threads
1,214,639
Messages
6,120,679
Members
448,977
Latest member
dbonilla0331

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