I am working on an excel document that will, in then end, have over 90 checkboxes. The user will be able to select any or all of the 90, which will in turn use only those values in a simple If...then function to Print the findings in an output document.
Originally my code used For i = 1 to 8, then I manually coded in the values that the checkboxes will now hold. i.e.
Dim Sec(1 to 8) as string
For i = 1 to 8
Sec(1) = "5001"
Sec(2) = "5002"
And so on until the values I needed were added. This wasn't too difficult, I was simply tailoring the document to whatever department needed it. However, as with all things that start small, I've been tasked with creating a document site wide that will encompass all the values that can be selected ad-hoc. It's here that I find myself lost.
I'm currently looking at using
For Each ctl in Sheets("Sheet1").Controls
If Typename(ctl) = "Checkbox" then
If ctl.value = True then
To cycle through all of the checkboxes and find the ones that are checked, but how would I take the value of checkbox one (lets say is 5001) and make that sec(#) to fall in line with the rest of my code?
Is this a dynamic array situation, or would I be better off simply sending the values to a column somewhere on the worksheet, then creating a Array from the range of cells not blank?
A larger segment of code, so you can get the jist of where everything falls is here. Please disregard the Attachmate stuff, I'm pulling information with Getstring into a separate document if certain conditions are met.
Dim Sec(1 To 8) As String
Sec(1) = "6601"
Sec(2) = "6602"
For i = 1 To 2
Sess0.Screen.Moveto 16, 19
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.SendKeys ("W")
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.Moveto 18, 28
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.SendKeys (Sec(i))
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.Moveto 17, 29
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.SendKeys ("19044")
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.Moveto 19, 60
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.SendKeys ("P")
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.SendKeys ("<enter>")
Do
'If.....then....else...
loop until errorcode = "End"
Next i
Any help would be greatly appreciated. I'm definitely trying to learn, but I seem to have come to a wall in my knowledge and I'm not quite sure where else to look.
Aucun commentaire:
Enregistrer un commentaire