Consulting

Results 1 to 3 of 3

Thread: Check the active workbook

  1. #1
    VBAX Mentor Sir Babydum GBE's Avatar
    Joined
    Mar 2005
    Location
    Cardiff, UK
    Posts
    499
    Location

    Check the active workbook

    I have a macro recorded in MyWorkbook.xls.

    The macro reorganises columns and picks up information from whatever workbook is the active one, copies it, then pastes it to MyWorbook.

    How can I get the macro to first check that MyWorkbook.xls isn't the active one - and if it is, put up a message: "Please activate the source workbook and re-run the macro" - and then exit the code? Whereas - if it's not the active book - it can carry on as normal.

    Thanks

    BD
    Have a profound problem? Need a ridiculous solution? Post a question in Babydum's forum

  2. #2
    If ActiveWorkbook Is ThisWorkbook Then
    'We're looking at the workbook with the code
    Else
    'Another workbook is active
    End If
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

  3. #3
    VBAX Mentor Sir Babydum GBE's Avatar
    Joined
    Mar 2005
    Location
    Cardiff, UK
    Posts
    499
    Location
    Quote Originally Posted by Jan Karel Pieterse
    If ActiveWorkbook Is ThisWorkbook Then
    'We're looking at the workbook with the code
    Else
    'Another workbook is active
    End If
    That's great thanks Jan!
    Have a profound problem? Need a ridiculous solution? Post a question in Babydum's forum

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •