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
 

sykes

Well-known Member
Joined
May 1, 2002
Messages
1,562
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,562
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:

Forum statistics

Threads
1,085,651
Messages
5,384,942
Members
401,927
Latest member
commae

Some videos you may like

This Week's Hot Topics

Top