External data validation

  • Thread starter Thread starter Shane
  • Start date Start date
S

Shane

I want to use external data validation. I know how to do it. What I
want to do is have a macro that automatically tells the user that the
external workbook needs to be open and will then open it. Does anyone
know how to do this?

Do I use a change event on the validation error?

Thanks in advance.

Shane
 
Hi shane,

One way is to attempt to activate the required workbook and if you get an
error then goto a routine to open it.

The newly opened workbook becomes the active one.

If workbook to open is not in the default path then you will need to add the
path in the wbOpen routine. Record a macro to open it will give you the
required syntax.

Example:

Sub Macro1()

Dim wbName As String

wbName = "Book2.xlsm"

On Error GoTo wbOpen
Windows(wbName).Activate
On Error GoTo 0

MsgBox "Workbook " & ActiveWorkbook.Name & " is open"

GoTo skipwbOpen 'When get to here skip wbOpen

wbOpen:
Workbooks.Open Filename:= _
"Book2.xlsm"
Resume Next

skipwbOpen:

End Sub

Hope it helps.

Regards,

OssieMac
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top