LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #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
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Variable statement doobie Excel Discussion (Misc queries) 3 November 11th 09 07:42 AM
Variable in if statement Francis Hookham Excel Worksheet Functions 9 December 12th 07 02:35 PM
using a variable for MOD Statement bethg7 Excel Programming 2 January 9th 07 02:16 AM
if than statement has too many variable repke New Users to Excel 1 May 2nd 06 02:00 PM
Macro Creating Variable and using variable in a SQL statement Jimmy Excel Programming 4 October 25th 04 02:36 AM


All times are GMT +1. The time now is 09:42 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"