this is my first time posting a question here. I am writing an MS Excel VBA project where I am passing a string between subroutines. In the second subroutine I am using the string to determine CASE conditions. EG 4000 to 9999; 4050 to 5000, 5050; 5051 to 6000, 6051 to 7000 being three examples. When these strings are typed after the CASE, it works , but passing the values as a string doesn't. My project involves the running of the sub many times with the case statement being required to change every time. Any Suggestions?
Many thanks NC here is a sample of my code. I have left out all the dims and calculations - I am positive that these would not help, thanks
Sub Calling_Sub ()
'Operating Income
Title = "Operating Income"
GL_Range = "5000 to 9499"
add_me_up Title, GL_Range
'Other Income
Title = "Other Income"
GL_Range = "4050 to 5000, 5050"
add_me_up Title, GL_Range
'Debts
Title = "Debts"
GL_Range = "5051 to 6000, 6051 to 7000"
add_me_up Title, GL_Range
'Other
Title = "Other"
GL_Range = "8051, 8055, 8070, 8075"
add_me_up Title, GL_Range
'and so on and so forth for all the other combinations
End Sub
Sub add_me_up (Title as string, GL_Range as string)
...
For Each lrowC In lrngC.Cells 'pivot table data rows
Select Case lrowC.Cells.Offset(0, 1)
Case ****GL_Range****
If lrowC.Cells(1, 1) = Fin_Year Then 'current month & YTD
Select Case Period
Case 1
...
end sub