SELECTING TEXT BOXES

mrbeanyuk

Board Regular
Joined
Nov 30, 2005
Messages
213
Afternoon all!

Can anyone tell me if it is possible to select all Text Boxes in a spreadsheet?

Thanks!
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Hi

If the textboxes are embedded in the worksheet, construct a ShapeRange collection with them and select it. Use Shapes.Range and in the range specify an array with the names of the TextBox controls.

Ex.
ActiveSheet.Shapes.Range(Array("TextBox1", "TextBox2")).Select

Why do you want to select them?

Hope this helps
PGC
 
Upvote 0
[

Thanks very much! The reason I need to select all of them is because I have 200+ text boxes all with black text then my boss came along as asked if they could all by changed to red! Charming!

Thanks
 
Upvote 0
Hi again

200+ text boxes ???

This code sets text to red in all the textboxes of the active worksheet.

Please test it:
Code:
Sub TextBoxesRed()
Dim shp As Shape

For Each shp In ActiveSheet.Shapes
    If shp.Type = msoOLEControlObject Then
        If shp.OLEFormat.ProgId = "Forms.TextBox.1" Then
            shp.OLEFormat.Object.Object.ForeColor = RGB(255, 0, 0)
        End If
    End If
Next shp
End Sub

Hope this helps
PGC
 
Upvote 0
Hello,

pgc01's macro works for me
was the sheet with textboxes active when running the macro ?

I changed one line: so try this
Code:
Sub TextBoxesRed()
Dim shp As Shape

For Each shp In ActiveSheet.Shapes
    If shp.Type = msoOLEControlObject Then
        If TypeName(shp.OLEFormat.Object.Object) = "TextBox" Then
            shp.OLEFormat.Object.Object.ForeColor = RGB(255, 0, 0)
        End If
    End If
Next shp
End Sub

alternatively
goto EDIT mode (leftop icon on CONTROLS-toolbar)
display properties window (next icon)
display drawing toolbar
Control+click all textboxes
in properties window change ForeColor

kind regards,
Erik
 
Upvote 0

Forum statistics

Threads
1,215,506
Messages
6,125,197
Members
449,214
Latest member
mr_ordinaryboy

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