|
-
Mar 5th, 2004, 10:08 AM
#1
Thread Starter
New Member
Concatenation question
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?
-
Mar 5th, 2004, 10:16 AM
#2
instead of this:
try this:
VB Code:
If Controls("checkbox" & N) = -1 Then
or this:
VB Code:
If FormName.Controls("checkbox" & N) = -1 Then
(where FormName is the name of the form)
-
Mar 5th, 2004, 11:16 AM
#3
Thread Starter
New Member
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
-
Mar 5th, 2004, 11:31 AM
#4
ok.. for a Worksheet it seems controls are stored as Shapes, so try this:
VB Code:
For Level = 0 To 9 Step 1
If S = True And (Sheets("Sheet1").Shapes("SLevel" & Level).Value = -1) Then
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|