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

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

sykes

Well-known Member
Joined
May 1, 2002
Messages
1,696
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,696
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,714
Messages
5,488,478
Members
407,639
Latest member
Carlos Ottoni

This Week's Hot Topics

  • Timer in VBA - Stop, Start, Pause and Reset
    [CODE=vba][/CODE] Option Explicit Dim CmdStop As Boolean Dim Paused As Boolean Dim Start Dim TimerValue As Date Dim pausedTime As Date Sub...
  • how to updates multiple rows in muliselect listbox
    Hello everyone. I need help with below code. code is only chaning 1st row in mulitiselect list box. i know issue with code...
  • Delete Row from Table
    I am trying to delete a row from a table using VBA using a named range to find what I need to delete. My Range is finding the right cell. In the...
  • Assigning to a variable
    I have a for each block where I want to assign the value in column 5 of the found row to the variable Serv. [CODE=vba] For Each ws In...
  • Way to verify information
    Hi All, I don't know what to call this formula, and therefore can't search. I have a spreadsheet with information I want to reference...
  • Active Cell Address – Inactive Sheet
    How to use VBA to get the cell address of the active cell in an inactive worksheet and then place that cell address in a location on the current...
Top