+ Reply to Thread
Results 1 to 7 of 7

inserting comments to cells based on the values of that cell and one other cell (VBA)

  1. #1
    Registered User
    Join Date
    01-06-2016
    Location
    London
    MS-Off Ver
    2013
    Posts
    2

    inserting comments to cells based on the values of that cell and one other cell (VBA)

    Hi all,

    I wish to set up a condition on cell whereby a comment box appears automatically if the user enters a certain value into that cell, BUT another cell (D12) is left blank.

    If the 'conditional' cell is blank (or equal to zero), and the cell itself (D29) is not equal to zero, then I want a comment appears to say "error".

    The code I have tried using is shown below. FYI it works with one criteria ie no "And Range("D29:AP29")", but i need both criteria to be accounted for in order for the condition to work.


    Please Login or Register  to view this content.
    Any help would very much appreciated!!

    Thanks,

    Michael
    Last edited by Richard Buttrey; 01-06-2016 at 11:53 AM. Reason: missing code tags

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: inserting comments to cells based on the values of that cell and one other cell (VBA)

    You cannot apply this to an entire range.
    I haven't tested but you would have to do it for each cell individually.
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: inserting comments to cells based on the values of that cell and one other cell (VBA)

    Hi and welcome to the forum. Unfortunately your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (Since this is your first post I'll change it for you but please note for the future)

    Wouldn't a conditional format which painted cells red where an error condition occurred be better than VB code?
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: inserting comments to cells based on the values of that cell and one other cell (VBA)

    Try this
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-06-2016
    Location
    London
    MS-Off Ver
    2013
    Posts
    2

    Re: inserting comments to cells based on the values of that cell and one other cell (VBA)

    Thanks Richard, I did not realise. Please find code below.

    Please Login or Register  to view this content.
    Keebalah, many thanks for your help, unfortunately though that comes up with nothing when a value is entered into D12 and no value into the cell itself D29.

    Any other ideas?

    Thanks,

    Michael

  6. #6
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: inserting comments to cells based on the values of that cell and one other cell (VBA)

    You said value = 0 then you have to edit and check on blank value instead of 0
    So I assume that you actually wnat to test on the value 0 and not on the fact if the cell is empty or not. Correct and thorough information is everything
    Please Login or Register  to view this content.
    I don't know if the countifs works correct this way but this would be the main idea

  7. #7
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: inserting comments to cells based on the values of that cell and one other cell (VBA)

    Try using this Worksheet_Change event procedure
    Please Login or Register  to view this content.

+ 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. Replies: 8
    Last Post: 06-27-2015, 03:21 PM
  2. [SOLVED] copy cell values in one cell based on value of adjacent cells
    By KK1234 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-20-2014, 08:48 AM
  3. Inserting images into a cell based on another cells value.
    By ccScotty in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-04-2012, 12:08 PM
  4. Inserting cells to the left based on cell value
    By Judge Dredd in forum Excel General
    Replies: 5
    Last Post: 03-11-2011, 04:39 AM
  5. Replies: 11
    Last Post: 07-26-2008, 05:18 AM
  6. [SOLVED] anchor comments to cell while inserting and deleting rows
    By db55ford in forum Excel General
    Replies: 1
    Last Post: 06-16-2006, 09:30 PM
  7. [SOLVED] UDF code to find specific text in cell comments, then average cell values
    By bruch04 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-05-2005, 06:10 PM

Tags for this Thread

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