+ Reply to Thread
Results 1 to 8 of 8

if blank do nothing vba

  1. #1
    Registered User
    Join Date
    10-25-2013
    Location
    canada
    MS-Off Ver
    Excel 2007
    Posts
    79

    if blank do nothing vba

    so i have a worksheet that has four columns with text that i enter manually. i created a vba code that will create a hyperlink to other workbooks in column B everytime certain text is entered, and that worked fine. the problem is i change the text often and insert and delete rows constantly, and when i insert a new row into the field i get the message "run-time error '13': type mismatch" and have to either end or debug every time.

    here is my code

    Please Login or Register  to view this content.
    i was wondering if there is a way to clean this code up and resolve the issue with an 'If blank - do nothing' or someting else

    thanks

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,719

    Re: if blank do nothing vba

    I understand your code but not your problem/question.

    Quote Originally Posted by hopefulhart View Post
    the problem is i change the text often and insert and delete rows constantly, and when i insert a new row into the field i get the message "run-time error '13': type mismatch"
    Do you mean you insert and delete rows in your worksheet, or you insert and delete lines of code? What does "insert a new row into the field" mean? What's "the field"?

    What line of code is indicated when you get that runtime error?

    If Target is blank, then your code will do nothing just the way it is. So I am not sure what you are getting at.

    Regardless, I would write the code like this (compiled and tested). I am taking advantage of the fact that the file name you are linking to is the same as the string in the target cell. If that assumption is not always true then this won't always work.

    Please Login or Register  to view this content.
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    10-25-2013
    Location
    canada
    MS-Off Ver
    Excel 2007
    Posts
    79

    Re: if blank do nothing vba

    thanks for the reply

    your new code works just as well except there are two folders that the hyperlinks go to, half are in CMHL Teams and the other half are in CHL Teams. yes i mean when i insert and delete rows on the worksheet i get the error message. on my original code it indicates this line
    Please Login or Register  to view this content.
    when i put your code in and selected row 2 on the worksheet and inserted a new row i got the same error message and it indicated these lines
    Please Login or Register  to view this content.

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,719

    Re: if blank do nothing vba

    Can you attach your file?

  5. #5
    Registered User
    Join Date
    10-25-2013
    Location
    canada
    MS-Off Ver
    Excel 2007
    Posts
    79

    Re: if blank do nothing vba

    yep here it is
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    10-25-2013
    Location
    canada
    MS-Off Ver
    Excel 2007
    Posts
    79

    Re: if blank do nothing vba

    so i found another post that seemed to fix the issue

    i added this line of code

    Please Login or Register  to view this content.
    thanks for all your help

  7. #7
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,719

    Re: if blank do nothing vba

    I didn't notice the two different leagues, I think this takes care of that.

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    10-25-2013
    Location
    canada
    MS-Off Ver
    Excel 2007
    Posts
    79

    Re: if blank do nothing vba

    thanks got it running nicely

+ 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] Concatenate If Blank - remove blank line if first cell is blank
    By ker9 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 05-27-2014, 02:14 PM
  2. Replies: 3
    Last Post: 01-23-2014, 12:19 PM
  3. [SOLVED] Simple pull exact text from cell, if blank it pulls up a 0. How to leave it as blank?
    By sharpmel in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-30-2012, 02:20 PM
  4. [SOLVED] If statement that copies text from a separate worksheet, or if blank, leaves cell blank.
    By barleycorn in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-22-2012, 12:30 PM
  5. Replies: 1
    Last Post: 03-21-2012, 09:41 AM

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