Object Name and For Loop

G

Gojavid

Good morning,
It has probably been asked before and it is definitely a
beginner's question, but any response it greatly appreciated.

I have a series of label boxes on a form and I need to set the caption
on each of them equal to a cell in the spreadsheet. I know how to do
this the long way:

label1.caption = cells(1,1)

but I was wondering if I could use a for loop and make this process a
little easier for the future... something like:

for i = 1 to 14
dim lbltest as object
set lbltest = "userform1.label" & i
lbltest.caption = cell(i +1,1)
next

any ideas?
 
G

Gojavid

I found some material on this subject from another newsgroup... Thanks
anyways:

dim txtbx as control
set txtbx = userform.control("txtbxHZ_" & i)
with userform
for i = 1 to 10
sheets("name").Range("name") = txtbx.value
next i
end with
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top