VBA code to clear range and text box

kroters

New Member
Joined
Jan 1, 2015
Messages
7
I have the below code which clears specific cells after a worksheet is emailed. I need to add TextBox1, TextBox2 and TextBox3 to the code to clear contents also. any help adding this into the below VBA code?





MsgBox "Your email was sent." & vbNewLine & "The form will now be reset.", vbInformation, "Success!"

Application.ScreenUpdating = False

Range("g10:j24,h27,h28,h30,h31,W28:W32,").Select
Selection.ClearContents
Range("d3").Select

Application.ScreenUpdating = True


End Sub
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Where are these textboxes? on a worksheet (if so, what's the name of the sheet) or on a userform?
 
Upvote 0
Hi

yes on a worksheet named Dashboard.

VBA assigned to a button that emails worksheet named dashboard and clears the sheet of inputted data.
the text boxes are "Text boxes (Activex)"
 
Upvote 0
This should work.
You've either not given the procedure a name, or only copied part of it into your post, so I've left the top part exactly as-is.
Code:
MsgBox "Your email was sent." & vbNewLine & "The form will now be reset.", vbInformation, "Success!"

Application.ScreenUpdating = False

Range("g10:j24,h27,h28,h30,h31,W28:W32,").Select
Selection.ClearContents

    With Sheets("Dashboard")
        .TextBox1.Value = ""
        .TextBox2.Value = ""
        .TextBox3.Value = ""
    End With


Range("d3").Select

Application.ScreenUpdating = True


End Sub
As you've not said where this code resides, I've also had to assume it's in a code module.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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