How to clear the interior colour of a textbox

danbates

Active Member
Joined
Oct 8, 2017
Messages
377
Office Version
  1. 2016
Platform
  1. Windows
Hi,

I have this following code which is my 'CLEAR' button on a search userform.

Code:
Private Sub CommandButton3_Click() Dim z As Control
 For Each z In Search.Controls
 If TypeName(z) = "TextBox" Then
 z.Value = ""
 End If
 Next z
 TextBox1.SetFocus
 End Sub

I would like to adapt it so when I press the 'CLEAR' button , not only does it clear the textboxes it also clears the interior colour of textbox7.

Any help would be much appreciated.

Kind Regards

Dan
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Code:
    dim ws as Worksheet
    set ws = ActiveSheet  ' assumes your text box is on the active sheet

     With ws.Shapes.Range("TextBox 7").Fill
        .Visible = msoTrue
        .ForeColor.ObjectThemeColor = msoThemeColorBackground1
        .ForeColor.TintAndShade = 0
        .ForeColor.Brightness = 0
        .Transparency = 0
        .Solid
    End With
 
Upvote 0
Hi,

Thank you for you response but my TextBox7 isn't on the active sheet. It is used in a userform called 'Search'

HTH

Regards

Dan
 
Upvote 0
Hi NoSparks,

That's just what I was after, Thank You.

Regards

Dan
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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