LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default If Then Else

I am trying to figure out how to set my macro to check a certain variable and
if it meets a specific variable to skip the rest of the macro and end.

If 'variable = X
Then 'skip to the end of the macro and end
Else 'continue on with the rest of the macro

I also am having trouble with some code I was given earlier.

Dim sh As Worksheet
Dim sStr As String

Set sh = ActiveSheet

sStr = "\\HCI\HCI Share\C of A's - Building 4\00-RMHTest-6
ParametersXXXX\"

If Dir(sStr & sh.Range("B7").Value) < "" Then
MsgBox "File Exists"
Else
MsgBox "File Does Not Exist"
End If

I was told this code would check if the value in B7 was the same as the file
name saved in the location "\\HCI\HCI Share\C of A's - Building
4\00-RMHTest-6
ParametersXXXX\" and if there was a file named the same as the value of B7
that I would get a message "File Exists" but if there was no file with the
name as the value in B7 then it would tell me that "File Does Not Exist".

The code above no matter what value I have in B7 it tells me "File Does Not
Exist" even if i use a value in B7 that already has a file saved as the value
in the location given.

Any help would be appreciated.
Thank you
Ryan Hess

 
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



All times are GMT +1. The time now is 07:30 PM.

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"