VBA: Getting value out variable Textbox (Tried it with Control)

L

lucky9999b

What i'm trying to do is the following:
If 2 criteria are met go trough all "TextBoxW" & i and check that there
value is not "". If they are not blank i want to perform an action whith this
value.
I have 53 TextBoxW so i could make an if function for each textbox but i'm
looking for some sorther code. Anyone any idea's?

Here is what i tried but didn't work since i can't extract a value out a
control or is there an other way?


Dim ctlWork As Control
Dim i As Integer
Dim ctlName As String
Sheets("RawData").Select
Dim Result As Integer


If ComboBoxAction = "Gratis" Or CommandButtonUpdate = True Then
i = TextBoxVanW.Value - 1
Do
i = i + 1
ctlName = "TextBoxW" & i
For Each ctlWork In UserForm.Controls
If ctlWork.Name = ctlName And ctlWork.value <> "" Then

Result = ctlWork.value + Cells(2, 3+i).value

End If
Next

Loop While i < TextBoxTotW.Value
End If
Sheets("RawData").Select


If ComboBoxAction = "Gratis" Or CommandButtonUpdate = True Then
i = TextBoxVanW.Value - 1
Do
i = i + 1
ctlName = "TextBoxW" & i
For Each ctlWork In UserForm.Controls
If ctlWork.Name = ctlName And GetValue(ctlWork) <> "" Then



End If
Next

Loop While i < TextBoxTotW.Value
End If
 
C

Cindy M.

Hi lucky,
Dim ctlWork As Control
Dim i As Integer
Dim ctlName As String
Sheets("RawData").Select
Dim Result As Integer
This appears to be VBA for Excel ("Sheets")? If yes, then
you should ask in the excel.programming newsgroup - this
group is specific for Word.

When you post, don't forget to mention the version of the
software. And also define more exactly what kinds of
textboxes these are (UserForm, embedded on a spreadsheet,
or...?).

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update
Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e-mail
:)
 

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