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

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
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,213,517
Messages
6,114,085
Members
448,548
Latest member
harryls

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