+ Reply to Thread
Results 1 to 5 of 5

If statement help with multiple sheets?

  1. #1
    Registered User
    Join Date
    05-13-2010
    Location
    NSW, AUS
    MS-Off Ver
    Excel 2007
    Posts
    3

    If statement help with multiple sheets?

    Hi, sorry i'm new to the forums and need some help.

    I'm trying to write an If Statement in Excel VBA but it is not working and i think it would probbably be something small that i missed but i still cant get my head around it.

    Basically i want to copy data from CurrentOrder to Database, which i can do, but i want to add a message box that says "Error" if the second sheet doesnt exist, ie has been deleted, moved or renamed. This is the coding i have done, i have indented the part where the error occurs:

    Please Login or Register  to view this content.
    If i run the code without the If statement it works fine, but if i use the if statement and change the sheet nam it doesn't work.
    Sorry if it is something small but like i said i just can't get my head around it, any help would be much appreciated.
    Cheers, Kezzby
    Last edited by kezzby; 05-19-2010 at 07:53 PM. Reason: Solved Problem

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,592

    Re: If statement help with multiple sheets?

    Please use CODE tags around your code. (#)

  3. #3
    Registered User
    Join Date
    05-13-2010
    Location
    NSW, AUS
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: If statement help with multiple sheets?

    Sorry, As i said i am a noob ha ha

  4. #4
    Forum Contributor
    Join Date
    12-03-2009
    Location
    Providence RI
    MS-Off Ver
    Excel 2007, Excel 2010
    Posts
    260

    Re: If statement help with multiple sheets?

    You need to include on error and is nothing statements. I would check this page in relation to how checking if a ws exists.

    http://www.ozgrid.com/VBA/IsWorkbookOpen.htm#WORKSHEET

    This is the basic code you would use:

    Please Login or Register  to view this content.
    Last edited by Dulanic; 05-13-2010 at 07:26 AM.

  5. #5
    Registered User
    Join Date
    05-13-2010
    Location
    NSW, AUS
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: If statement help with multiple sheets?

    Thank you for all your help, it worked really well, hopefully one day i could help you with something. Cheers, kezzby.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1