View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default How to use the if statement for Macro coding?

Simpler:-

Sub human()
Application.DisplayAlerts = False
Path = "c:\"
WorkbookName = "Book2.xls"
Sheet = "Sheet1"
Addr = "A1"
Worksheets.Add
Range("A1").Formula = "='" & Path & "\[" & WorkbookName & "]" & Sheet & "'!"
& Addr
TheValue = Range("A1").Value
ActiveSheet.Delete
If TheValue = 1 Then
Workbooks.Open Filename:="c:\book2.xls", UpdateLinks:=3
Workbooks("book2.xls").Close savechanges:=True
Else
MsgBox ("The value was " & TheValue)
End If
End Sub


Mike

"Eric" wrote:

IF( 'E:\file\[1.xls]Sheet1'!$A$1 = 1 THEN
{ / Processing following code
Workbooks.Open Filename:="E:\file\1.xls", UpdateLinks:=3
Workbooks("1.xls").Close savechanges:=True
} else
/ Processing nothing

Does anyone have any suggestions on how to code the if statement for Excel
Macro?
Thank in advance for any suggestions
Eric