Microsoft Office Forums

Go Back   Microsoft Office Forums > Microsoft Word > Word VBA

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 04-17-2019, 05:06 AM
blaisjoel blaisjoel is offline Windows 7 64bit Office 2016
Novice
 
Join Date: Apr 2019
Posts: 1
blaisjoel is on a distinguished road
Default Combobox Looping

I want to be able to loop through my comboboxes using a variable (i)

This is what I have

Code:
   ElseIf ComboBox1.Value = "PICKUP" Then
        Load UnitForm
        UnitForm.Tag = 1


UnitForm.Show TextBox1.Value = "8 cm high" TextBox2.Value = "33 cm high" TextBox3.Value = "7.5 cm high"
This is what I tried

Dim i as integer

ElseIf ComboBox & i.Value = "PICKUP" Then
Load UnitForm
UnitForm.Tag = 1
UnitForm.Show
TextBox1.Value = "8 cm high"
TextBox2.Value = "33 cm high"
TextBox3.Value = "7.5 cm high"

It doesn't like the variable.
Reply With Quote
  #2  
Old 04-17-2019, 05:50 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 2,706
gmayor is just really nicegmayor is just really nicegmayor is just really nicegmayor is just really nice
Default

Is this a userform? You can loop through the controls collection e.g.

Code:
Dim i As Integer
Dim oCtrl As Control
    For Each oCtrl In Controls
        If TypeName(oCtrl) = "ComboBox" Then
            If oCtrl.value = "Pickup" Then
                'do stuff with oCtrl e.g.
                MsgBox oCtrl.Name
                Exit For
            End If
        End If
    Next oCtrl
__________________
Graham Mayor - MS MVP (Word)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Looping through emails knarfreppep Outlook 2 04-07-2018 08:03 AM
Looping several slides gabby PowerPoint 11 04-25-2015 03:05 AM
Need help on macro for looping kilosub Word VBA 31 07-27-2011 01:37 PM
Looping Question Steve B PowerPoint 0 01-19-2011 10:44 AM
Looping video tomasball PowerPoint 0 10-30-2010 02:38 PM


All times are GMT -7. The time now is 09:19 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
MSOfficeForums.com is not affiliated with Microsoft