VBA code to clear range and text box

kroters

New Member
Joined
Jan 1, 2015
Messages
6
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
 

Some videos you may like

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

sykes

Well-known Member
Joined
May 1, 2002
Messages
1,683
Office Version
365
Platform
Windows
Where are these textboxes? on a worksheet (if so, what's the name of the sheet) or on a userform?
 

kroters

New Member
Joined
Jan 1, 2015
Messages
6
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)"
 

sykes

Well-known Member
Joined
May 1, 2002
Messages
1,683
Office Version
365
Platform
Windows
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:

Watch MrExcel Video

Forum statistics

Threads
1,102,285
Messages
5,485,848
Members
407,521
Latest member
marita

This Week's Hot Topics

Top