I have a multipage user form. Each page has multiple textboxes. I have written VBA code, triggered by a command button, to copy the code to another sheet in the workbook. This code works fine. In the same sub, i have code that clears the value of each textbox (Me.MB50101.Value = ""). This works fine, but it seems to me that clearing the textboxes can be done more efficiently. I found a bit of code that presumably loops through all textboxes on a single page of the userform and clears the code:
The code does not throw an error but also does not clear the textboxes. I believe my error is the use of wildcards in the TypeName. There are three potential formats for the names of the textboxes:Please Login or Register to view this content.
MB50101 - The first two letters and last two numbers can change (body cells)
MB501Total - The first two letters can change (column total)
GTotal50101 - The last two letters can change (row total)
is there is single "*501##*" that can address this? If so, i cannot figure this out. Otherwise, do i need multiple if then conditions? Also, this code was triggered by a separate command button; i want to embed this code in the macro that copies the values to the separate sheet.
The "501" embedded in the textbox name identifies all textboxes on Page 1 of the userform. Page two textboxes use 502; Page three, 503, etc.
Appreciate any wisdom that can be provided.
Bookmarks