I could not figure out how to use the control arrays in VBA for Excel. Can somebody give me a hint how to use a loop instead of having the code I do.
I use soemthing like this a lot in my application and I know it is wrong, but don't know how to loop through controls or cells. I am new in VB. I would appriciate any help. Thanks.
Code:
txtNoUnits1.Text = Format(txtNoUnits1.Text, "##,###,##0")
txtNoUnits2.Text = Format(txtNoUnits2.Text, "##,###,##0")
txtNoUnits3.Text = Format(txtNoUnits3.Text, "##,###,##0")
txtNoUnits4.Text = Format(txtNoUnits4.Text, "##,###,##0")
txtNoUnits5.Text = Format(txtNoUnits5.Text, "##,###,##0")
txtNoUnits6.Text = Format(txtNoUnits6.Text, "##,###,##0")
txtNoUnits7.Text = Format(txtNoUnits7.Text, "##,###,##0")
txtNoUnits8.Text = Format(txtNoUnits8.Text, "##,###,##0")
txtNoUnits9.Text = Format(txtNoUnits9.Text, "##,###,##0")
txtNoUnits10.Text = Format(txtNoUnits10.Text, "##,###,##0")
txtNoUnits11.Text = Format(txtNoUnits11.Text, "##,###,##0")
txtNoUnits12.Text = Format(txtNoUnits12.Text, "##,###,##0")
txtNoUnits13.Text = Format(txtNoUnits13.Text, "##,###,##0")
txtNoUnits14.Text = Format(txtNoUnits14.Text, "##,###,##0")
txtNoUnits15.Text = Format(txtNoUnits15.Text, "##,###,##0")
I use soemthing like this a lot in my application and I know it is wrong, but don't know how to loop through controls or cells. I am new in VB. I would appriciate any help. Thanks.