command button

S

saziz

I created 2 command button on user form. How can I write a code to put
a set of data in a particular range if a button1 is clicked and
simillarly into a different range if button2 is clicked.
Appreciate your help.

Thank you
Syed
 
L

Leith Ross

Hello Saziz,

Here is an example using a command button named CommandButton1. You ca
change this to match your command buttons. The Range is on Sheet1, cell
A1 to A3. Be sure to change these to match your code also.

Sub CommandButton1_Click()
With Worksheets("Sheet1")
.Cells(1, "A").Value = "A"
.Cells(2, "A").Value = "B"
.Cells(3, "A").Value = "C"
End With
End Sub

Sincerely,
Leith Ros
 

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