jardenp
Active Member
- Joined
- May 12, 2009
- Messages
- 373
- Office Version
- 2019
- 2016
- 2013
- 2011
- 2010
- Platform
- Windows
In a Userform I have three groups of maybe 30 text boxes, command buttons, radio buttons, etc. The groups are identical except for the number in the object names. For example, I have 3 text boxes: LastName_TB1, LastName_TB2, and LastName_TB3; or 3 command buttons: ProcessScan_CB1, ProcessScan_CB2, and ProcessScan_CB3. It's in groups because I have command buttons that copy certain data down to the next group, making it much faster for the person entering data.
At the bottom there is a command button to process the data. That command button will run a series of checks and data moves to each group separately.
Is there a way to write a script that I could run a 3-iteration loop on to change the object names or do I just need to make copies of the finished scripts and, say, replace all "TB1" with "TB2", "CB1" with "CB2", etc.? I'm thinking something along the lines of
Where "i" become part of the object name.
I mean...I can copy and replace...but it's probably 250 lines of code to "process" a group, any future change would have to be made in three places, sounds like a pain to get straight, reading through copies to make sure the find and replace went ok, etc.
Thank you!
At the bottom there is a command button to process the data. That command button will run a series of checks and data moves to each group separately.
Is there a way to write a script that I could run a 3-iteration loop on to change the object names or do I just need to make copies of the finished scripts and, say, replace all "TB1" with "TB2", "CB1" with "CB2", etc.? I'm thinking something along the lines of
VBA Code:
For i = 1 to 3
...
LastName_TB&i.copy Sheets(Destination)...
...
Next i
I mean...I can copy and replace...but it's probably 250 lines of code to "process" a group, any future change would have to be made in three places, sounds like a pain to get straight, reading through copies to make sure the find and replace went ok, etc.
Thank you!