JasonEnsor
Programmer
Hi Guys,
I have the following declared in my excel workbook, as my case statement loops through several faculties i would like to reduce the amount of repeated code. I was hoping to be able to access a variable by concatenating a string with a counter variable. i have done this using controls on a userform but can not workout how to do this for variable values.
I would like to concatenate "cw" with a counter value to then access the cw1, cw2, cw3 values
Any help would be appreciated
J.
I have the following declared in my excel workbook, as my case statement loops through several faculties i would like to reduce the amount of repeated code. I was hoping to be able to access a variable by concatenating a string with a counter variable. i have done this using controls on a userform but can not workout how to do this for variable values.
I would like to concatenate "cw" with a counter value to then access the cw1, cw2, cw3 values
Any help would be appreciated
J.
Code:
cw1 = ThisWorkbook.Sheets("Sheet1").Range("F" & currentRow)
cw2 = ThisWorkbook.Sheets("Sheet1").Range("H" & currentRow)
cw3 = ThisWorkbook.Sheets("Sheet1").Range("J" & currentRow)
ex1 = ThisWorkbook.Sheets("Sheet1").Range("L" & currentRow)
ex2 = ThisWorkbook.Sheets("Sheet1").Range("N" & currentRow)
ex3 = ThisWorkbook.Sheets("Sheet1").Range("P" & currentRow)
Select Case faculty
Case "ADT"
For Counter = 1 To 3
cName = ("cw" & Counter)
If cName <> "" And cName < 20 Then
Select Case semester
Case "A"
AdtA = AdtA + 1
Case "S"
AdtS = AdtS + 1
Case "T"
AdtT = AdtT + 1
Case Else
AdtO = AdtO + 1
End Select
End If
cNameEx = "ex" & Counter
If cNameEx <> "" And cNameEx < 20 Then
Select Case semester
Case "A"
AdtAE = AdtAE + 1
Case "S"
AdtSE = AdtSE + 1
Case "T"
AdtTE = AdtTE + 1
Case Else
AdtOE = AdtOE + 1
End Select
End If
Next Counter
.....