Select the text boxes on a sheet.
TeRRanCe73290
Posted messages
1
Registration date
Status
Member
-
le père -
le père -
Hello everyone,
I am working on Excel Pro 2003 and I can't find how to select all the text boxes on a sheet in my workbook via VBA.
The goal is to assign the value "" to all the text boxes on my sheet (to clear them...) without knowing their names. Indeed, there are about thirty text boxes on the same sheet and as many on the next sheet, I need to be able to clear them easily even if I add or remove some over time.
Does anyone have any ideas?
Thanks in advance.
I am working on Excel Pro 2003 and I can't find how to select all the text boxes on a sheet in my workbook via VBA.
The goal is to assign the value "" to all the text boxes on my sheet (to clear them...) without knowing their names. Indeed, there are about thirty text boxes on the same sheet and as many on the next sheet, I need to be able to clear them easily even if I add or remove some over time.
Does anyone have any ideas?
Thanks in advance.
1 answer
Hello
While waiting for someone to suggest something good to you, there are two solutions, neither really satisfactory:
dim ctrl as control
for each ctrl in tafeuille.controls
...
next ctrl
With this, you loop through all the controls. You've probably done this before; I'm just reminding you in case
Now you need to distinguish the Textboxes from the rest.
1 - You can use an on error resume next and "brutally" set ctrl.text="" instead of ...
2 - You can use the Tag property of the controls and put a specific value in it for all Textboxes. In the loop, you test this property (which exists for all controls - I believe - to check if it is a textbox.
While waiting for someone to suggest something good to you, there are two solutions, neither really satisfactory:
dim ctrl as control
for each ctrl in tafeuille.controls
...
next ctrl
With this, you loop through all the controls. You've probably done this before; I'm just reminding you in case
Now you need to distinguish the Textboxes from the rest.
1 - You can use an on error resume next and "brutally" set ctrl.text="" instead of ...
2 - You can use the Tag property of the controls and put a specific value in it for all Textboxes. In the loop, you test this property (which exists for all controls - I believe - to check if it is a textbox.