Is it possible to use a variable expression in VBA for a form label?
I want to place 100 different values for 100 different labels on a form. I can do it simply with the following loop, but VBA won't accept any syntax I have tried for the label name. For CT = 1 to 100 [Forms]![F3-subject index]!["sn"&CT].Caption=valuearray(CT) next CT
How can this loop be accomlished?
- If you need clarification, ask it in the comment box above.
- Better answers use proper spelling and grammar.
- Provide details, support with references or personal experience.
Tell us some more! Your answer needs to include more details to help people.You can't post answers that contain an email address.Please enter a valid email address.The email address entered is already associated to an account.Login to postPlease use English characters only.
Tip: The max point reward for answering a question is 15.
You can set a default value in most form items under the properties of that item. Look for "value". You can also do this in code, by setting up a sub routine to set/reset the values on your form. Then just run the sub routine before you open or enter the form.
Private Sub resetForm()
'formname.itemname = value UserForm1.Label1 = "Hello World"
For the second one you have a couple of options, you can find the bottom on the data and store the row index in a variable, use a loop to find the next empty cell in a row, and store the value or you can use the current region method to select all the cells with data continously touching the selected range. Example below
Ignore the warning (it's there for your protection). Do a search for your default page and / or insert it into your expression, presumably a script of some sort from (who knows where and being a bit more specific would have helped....grrr). The last problem might be because you have them located in a different area (folder). Check and see. Search (or find) on the name of one that does show and one that does not appear.
If you follow the Mail Merge instructions built into Microsoft Word's Mail Merge Wizard, you can use your Excel file as the data source for your Mail Merge document, which can be created using label templates built into Word or downloaded from the label manufacturer's website. If you need more detailed instructions, please let us know what version of Microsoft Office you're using, as well as the Operating System (PC or Mac, Windows '98, XP, Vista, Leopard, etc.) and the label manufacturer and label name and product number. Please let us know if you need more help.