I have a form with 7 combo boxes on it and I'd like to take the values
from the selections and store the value into an array. Some
background: The first two combo boxes must be selected otherwise the
form should not do anything. As long as the first two equal a value,
the rest of them *could* be blank or contain a value. What I'd like
to do is grab all of the values that aren't blank and resize my array
with these values. I'm a bit green with arrays, so a layman's
approach would go a long way. Here's the code I have already:
Dim cCont As Control
Dim arrDeviceVal() As String
Dim i As Integer
i = 0
'I'm stuck on the logic for this array
'Finds vals for Devices and ReDim's the array
For Each cCont In Me.Controls
If TypeName(cCont) = "ComboBox" Then
arrDeviceVal = ????
'Also when I type: cCont. I do not get a property of Value
as I would expect. How am I to get the value of the combo box then?
End If
Next cCont
For i = 0 To UBound(arrDeviceVal)
MsgBox arrDeviceVal(i)
Next i
If cmb1.Value = "" Or cmb2.Value = "" Then
MsgBox "Device 1 and Device 2 cannot be blank. Choose a
device for both of these to continue.", vbCritical
Else
'ActiveWorkbook.Sheets("ALL FILE").Range("C" & (intCellRow -
8)).Value = arrDeviceVal(0)
Unload Me
End If
Thanks for any insight!!!
Cheers,
Matt
--
----------------------------------------------------------------------------------
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links :
http://twitter.com/exceldailytip
2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
To post to this group, send email to [email protected]
<><><><><><><><><><><><><><><><><><><><><><>
Like our page on facebook , Just follow below link
http://www.facebook.com/pages/discussexcelcom/160307843985936?v=wall&ref=ts