+ Reply to Thread
Results 1 to 5 of 5

VBA code that adds comment to cell by userform; runtime error 1004 when left blank

  1. #1
    Registered User
    Join Date
    07-07-2014
    Location
    London, England
    MS-Off Ver
    Professional 2010
    Posts
    14

    VBA code that adds comment to cell by userform; runtime error 1004 when left blank

    Hi all,

    I found some code that allows the user to enter comments into a specific cell through entry on the userform. Now the code works perfectly whenever someone enters something that should be added as a comment. However, when this field is left blank I get a runtime error 1004 when I would want it to refrain from adding a comment. I pasted the code below;
    Please Login or Register  to view this content.
    In debug mode the line 'rng.AddComment Me.TextBox2.Text' is highlighted. Can anyone help me?
    Last edited by Leith Ross; 07-26-2014 at 12:36 PM. Reason: Added Code Tags

  2. #2
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: VBA code that adds comment to cell by userform; runtime error 1004 when left blank

    try this...

    Please Login or Register  to view this content.
    I replaced the empty text with a space..

    Don't forget to click *

  3. #3
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: VBA code that adds comment to cell by userform; runtime error 1004 when left blank

    Please Login or Register  to view this content.
    If solved remember to mark Thread as solved

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

    Re: VBA code that adds comment to cell by userform; runtime error 1004 when left blank

    Perhaps.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  5. #5
    Registered User
    Join Date
    07-07-2014
    Location
    London, England
    MS-Off Ver
    Professional 2010
    Posts
    14

    Re: VBA code that adds comment to cell by userform; runtime error 1004 when left blank

    Thanks so much patel45, that did it!

+ 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] Match & Index code results in Runtime error 1004
    By DJvdW in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-27-2013, 03:52 AM
  2. [SOLVED] 'Runtime Error 1004' when trying to Rename Worksheet using vba code
    By Raporter65 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-28-2013, 07:43 PM
  3. [SOLVED] Range error in code, runs alone but not inside my full program, giving runtime error 1004
    By charizzardd in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-23-2012, 03:34 PM
  4. Runtime error '1004' Application-defined or object-defined error Comment
    By Willer in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-17-2011, 03:02 PM
  5. Runtime Error Code 1004
    By laks in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-19-2007, 07:08 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