PDA

Click to See Complete Forum and Search --> : Concatenation question


tonybrown3
Mar 5th, 2004, 09:08 AM
Is there any concatenation for anything but strings? I have several check boxes in an excel sheet.

checkbox1
checkbox2
checkbox3..... etc

I would like to run concantenation within a loop where I do something like this sudo code....


For N = 1 to 10 Step 1

If checkbox(N) = -1 Then

do something

End If

Next N


I have working code that does what I want, but I have an If.. Then statement for every box on the sheet. If I could collapse this into a loop it would clean up my code alot. The only concatenation references I can find only talk about text. Any suggestions?

si_the_geek
Mar 5th, 2004, 09:16 AM
instead of this:
If checkbox(N) = -1 Then

try this:If Controls("checkbox" & N) = -1 Then

or this:If FormName.Controls("checkbox" & N) = -1 Then(where FormName is the name of the form)

tonybrown3
Mar 5th, 2004, 10:16 AM
hmm.... the only thing I did was open up the design mode and use the tool box to drop my check boxes on to the spreadsheet. I didn't add a form. I added a module1 to put all my code in because for some reason it would only let me do two Sub type proceedures in the edit code for my button to start the process. Now that I am home here is a snipit of the code I would like to edit by a loop. SLevel0 is the name of the check box. I have several like SLevel1, SLevel2... so thus I would like to put the N/Level in the numbers area.

For Level = 0 To 9 Step 1
If S = True And (Sheets("Sheet1").SLevel0.Value = -1) Then
For N = 1 To 300 Step 1
If (Sheets("Sheet3").Cells(N, 2) = Level) And (Sheets("Sheet3").Cells(N, 25) = "Simple") Then
Sheets("Sheet2").Cells(tracker, 1) = Sheets("Sheet3").Cells(N, 1)
tracker = tracker + 1
End If
Next N
End If

If C = True And (Sheets("Sheet1").CLevel0.Value = -1) Then
For N = 1 To 300 Step 1
If (Sheets("Sheet3").Cells(N, 2) = Level) And (Sheets("Sheet3").Cells(N, 25) = "Complex") Then
Sheets("Sheet2").Cells(tracker, 1) = Sheets("Sheet3").Cells(N, 1)
tracker = tracker + 1
End If
Next N
End If

If E = True And (Sheets("Sheet1").ELevel0.Value = -1) Then
For N = 1 To 300 Step 1
If (Sheets("Sheet3").Cells(N, 2) = Level) And (Sheets("Sheet3").Cells(N, 25) = "Exotic") Then
Sheets("Sheet2").Cells(tracker, 1) = Sheets("Sheet3").Cells(N, 1)
tracker = tracker + 1
End If
Next N
End If

tracker = tracker + 1
Next Level

si_the_geek
Mar 5th, 2004, 10:31 AM
ok.. for a Worksheet it seems controls are stored as Shapes, so try this:

For Level = 0 To 9 Step 1
If S = True And (Sheets("Sheet1").Shapes("SLevel" & Level).Value = -1) Then