Urgently Need If Statement, Please

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I need an If statement that validates the name of the Excel Workbook that is
opened but I'm not sure how to complete it. I'm thinking something like
this...


Dim wbName As String 'holds the name of the opened workbook

wbName = Application.ActiveWorkbook.Name 'get the workbook name

If wbName = "BlankDataWorkbook.xls" Then 'verifies the name
Do This Stuff 'performs the action
Else 'if it isnt the name then do the following
Exit Sub 'exits the sub
End If 'close the if statement


Is this even close???

Thanks Much In Advance,
Rob
 
You don't say what "validates" really means, but your code would seem to
work to exit the procedure if the active workbook's name isn't
"BlankDataWorkbook.xls".

An alternative might be:

If Application.ActiveWorkbook.Name <> "BlankDataWorkbook" Then Exit Sub
'Do This Stuff
 
Back
Top