Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mass Replace on Excel Userforms

Status
Not open for further replies.

senators40

Technical User
Jan 7, 2003
68
CA
Hi,

I have a userform that has textboxes (approx 200) that have to be updated occasionally

Some sample textbox names are:

Salaries_2006
Land_2006

I would like to change them to

Salaries_2007
Land_2007

Is there any way of using some sort of find / replace for the names in textboxes. The find / replace can be used for the actual visual basic text but it doesn't seem to work with the textboxes.

I also have "labels" that need to be updated as well

Any help would be appreciated

Thanks,

Jeff
 
untested.....
Code:
For each ctrl in controls
 if right(ctrl.name),4) = "2006" then
   ctrl.name = Left(ctrl.name,len(ctrl.name)-4) & "2007"
 end if
next

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top