+ Reply to Thread
Results 1 to 7 of 7

Blank cell gives error 13 (Mismatch) in loop - edit code to accommodate for blanks

  1. #1
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Blank cell gives error 13 (Mismatch) in loop - edit code to accommodate for blanks

    Hi guys,

    I hope you can help me.

    I have a procedure that loops through a range of cells, updating my spreadsheet with the required data. But when one of my cells is blank in my range, I get an error. How can I edit my code to not see my blank cell as an error? Just moves on?

    Note: I have underlined the part in the code where the loop starts.

    Please Login or Register  to view this content.
    Thank you in advance!
    Last edited by onmyway; 04-17-2015 at 07:37 AM.
    Sharing knowledge, can be likened to taking another person's hand, and pulling them up to a higher level -- onmyway

    If I was helpful, please remember to click on * Add Reputation below

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Blank cell gives error 13 (Mismatch) in loop - edit code to accommodate for blanks

    Maybe:

    Add an If statement at that location.

    Please Login or Register  to view this content.

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Blank cell gives error 13 (Mismatch) in loop - edit code to accommodate for blanks

    Where do you actually get the error?
    If posting code please use code tags, see here.

  4. #4
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Re: Blank cell gives error 13 (Mismatch) in loop - edit code to accommodate for blanks

    Hi John,

    Thank you for the responce.

    I have tried it like this:

    Please Login or Register  to view this content.
    But get the same error.

    i have also tried it as:

    Please Login or Register  to view this content.
    Also the same error....

    Am I putting it in the right place?

  5. #5
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Re: Blank cell gives error 13 (Mismatch) in loop - edit code to accommodate for blanks

    Quote Originally Posted by Norie View Post
    Where do you actually get the error?
    Hi Norie,

    I believe the error occurs when the loop compares my destination cell with my source cells, and where this destination cell is blank. The loop moves down in my range of destination cells with the "next Dcell" method, and when one of these Dcell are empty, I get the error.

    Hope it makes sense!

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Blank cell gives error 13 (Mismatch) in loop - edit code to accommodate for blanks

    I don't see how that would cause a type mismatch.

    Can you identify which line of code the error actually occurs on?

  7. #7
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Re: Blank cell gives error 13 (Mismatch) in loop - edit code to accommodate for blanks

    I have found my mistake.....

    I had my Zero (0) values formatted to show as blanks in my custom format: 0;-0;;@

    Therefore this did not work:

    Please Login or Register  to view this content.
    Thank you all!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Find first non-blank cell after a group of blanks copy offset cells, find next blank, loop
    By gwsampso in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-21-2012, 06:11 AM
  2. Edit code to loop error msgbox and inputbox until valid date is entered by user.
    By rocksan in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-11-2012, 10:07 PM
  3. Replies: 4
    Last Post: 08-29-2012, 02:45 PM
  4. Mismatch error from nested Do While loop?
    By scope951 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-26-2010, 01:01 PM
  5. Error 13 Type Mismatch in For Next Loop
    By VBAxellence in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-30-2009, 12:47 PM

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