Command Button to return a default text

ellehcer08

New Member
Joined
Jul 25, 2011
Messages
31
Hi! I need to know when the command button is clicked, it will return a specific text or number... Like when I need to click "RESET BUTTON", it will clear the contents is the given range with this code:

Private Sub CommandButton1_Click()
Range("c8:c42").ClearContents
End Sub

But what will be the code if I want to clear a certain range of cells and return a default number "1".
Please help, I'm really confuse with the codes.

And also, if I am using a textbox, and I want to put the number there, and I want to clear that too, what will be the code?

Thanks a lot... Hope someone will help me on this..
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Do you mean?

Code:
Private Sub CommandButton1_Click()
Range("c8:c42").Value = 1
End Sub
 
Upvote 0
Do you mean?

Code:
Private Sub CommandButton1_Click()
Range("c8:c42").Value = 1
End Sub
yup! exactly what i was looking for... thanks a lot!
but if i am using a textbox, how can i clear that up and can i use the number in that box for a formula in a cell?
 
Upvote 0

Forum statistics

Threads
1,224,517
Messages
6,179,242
Members
452,898
Latest member
Capolavoro009

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