![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Mar 2002
Location: Tennessee
Posts: 25
|
Hi All:
I've found a new snag with my forms, one has 25 check boxes and 50 text boxes. The other will have that many if not more. Of course all of them are creativly named checkbox1, checkbox2,...textbox1, textbox2,....etc and so forth. The $64 question is: Is there a quick and easy way to write code for all these check and text boxes? Here is a sample of the code for checkbox1. Private Sub CheckBox1_Click() If CheckBox1 = True Then TextBox1.Visible = True TextBox1.SetFocus TextBox2.Visible = True ElseIf check = False Then TextBox1.Value = Clear TextBox2.Value = Clear TextBox1.Visible = False TextBox2.Visible = False End If End Sub Try typing all that in 25 times as fast as you can The textboxes will be paired (tb 1 with tb2 and so forth) and will have their own code to copy values to a worksheet. (would like a quick way to code this too.) Any one have any ideas, or am I stuck with a whole butt load of typing? Thanks for helping Dave |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Apr 2002
Location: Vancouver BC , Canada
Posts: 6,259
|
Wouldn't making object arrays make your work easier ?
An object array for text boxes , checkboxes etc. |
|
|
|
|
|
#3 |
|
New Member
Join Date: Mar 2002
Location: Tennessee
Posts: 25
|
Hi again Nimrod:
Unfortunatly, I have only the faintest idea of how to use arrays (every time I try reading about them my head slams into the desktop at a high rate of speed). Thanks for the help and the quick post Dave |
|
|
|
|
|
#4 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
|
It would be easier, were it not for the fact that object arrays are not native to VBA6.
You can simulate object arrays using class modules, but this is quite a pain to set up and your error trapping needs to be spot on. (or else any error can destroy your objects) There may be an example of how to do this on this board. _________________ [b] Mark O'Brien [ This Message was edited by: Mark O'Brien on 2002-05-05 21:59 ] |
|
|
|
|
|
#5 | |
|
MrExcel MVP
Join Date: Mar 2002
Location: Kobe, Japan
Posts: 1,420
|
Quote:
Please try. sorry I can not explain this in English.
|
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|