View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Rob Rob is offline
external usenet poster
 
Posts: 718
Default Using a variable in an If statement

Hello All,

Is there a way to use a variable in an If statement? I have collected some
information in one part of my subroutine and would like it to be the
conditional of the If statement like this:

Workbooks(orgFile).Worksheets("Cost Centers").Activate
Range("C2").Select
strGetCostCenter = """" & "790-30-00" & """" & " OR Temp = " & """" &
ActiveCell.Value & """"""
ActiveCell.Offset(1, 0).Range("A1").Select

Do Until ActiveCell = ""
strGetCostCenter = strGetCostCenter & " OR Temp = " & """" &
ActiveCell.Value & """"
ActiveCell.Offset(1, 0).Range("A1").Select
Loop


If Temp = strGetCostCenter Then


endif

If have looked at the results of the strGetCostCenter variable and it
matches exactely what I would use manually in the If statement.

Any suggestions would be greatly appreciated.

Regards,

Rob