+ Reply to Thread
Results 1 to 7 of 7

Is worksheet empty (blank)

  1. #1
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,163

    Is worksheet empty (blank)

    How do you know if a worksheet is empty (blank)? I am using the following code to populate a worksheet.
    Please Login or Register  to view this content.
    If sheet(5) is not blank I want to delete all data and repopulate (trying to prevent duplicate data on sheet 5).
    Once I know how to detect a blank worksheet I can then prompt the user via a MsgBox.

    Edit:
    I will be using coulumns "A" thru "Z" only, row numbers will be variable.
    Regards

    Rick
    Win10, Office 365

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Something like

    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good afternoon Rick_Stanich

    Perhaps :
    Please Login or Register  to view this content.
    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  4. #4
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,163
    Some times, the obvious hurts.

    Thanks

  5. #5
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,163
    with this new information I modified my code to this.
    Please Login or Register  to view this content.
    My problem is, if the sheet is blank, the code jumps to the end and reads MsgBox "Operation completed!" with out collecting my data.

    I do not see where my error is.

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    o you want the code to run if the sheet is empty? I would really have thought it would have been easier to just build the deletion of data into the code, maybe with a warning first.

    Is this what you want/
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,163
    Quote Originally Posted by royUK
    o you want the code to run if the sheet is empty? I would really have thought it would have been easier to just build the deletion of data into the code, maybe with a warning first.

    Is this what you want/
    Now see what you did? You made me think! Your obviously not aware of the dangers involved with that, black holes collapse, quantum theory is out the window.

    Who said this quote?
    I became insane with long intervals of horrible sanity!



    Turns out it was this easy to fix. Test an either or condition then issue a prompt.
    Please Login or Register  to view this content.
    Thanks to all!

+ 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