+ Reply to Thread
Results 1 to 16 of 16

How to read left side cell value to the comment cell

  1. #1
    Registered User
    Join Date
    05-09-2010
    Location
    Chicago, US
    MS-Off Ver
    Excel 2003
    Posts
    11

    How to read left side cell value to the comment cell

    I can read all comments in excel file using below code. How do I read left side cell value to the comment cell?

    Please Login or Register  to view this content.

    sample data:
    A B C Col B comments
    ---------------
    a1 b1 c1 b1 comment
    a2 b2 c2 b2 comment

    expected output:
    ------------------------
    left side cell val Col B comments
    ----------------------------------------------------------
    a1 b1 comment
    a2 b2 comment


    Please find attached test.xls for sample. Thanks.
    Attached Files Attached Files

  2. #2
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: How to read left side cell value to the comment cell

    gsr
    not to sure what you need but this will show the comments
    Please Login or Register  to view this content.
    Last edited by pike; 05-13-2010 at 11:57 PM.
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  3. #3
    Registered User
    Join Date
    05-09-2010
    Location
    Chicago, US
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: How to read left side cell value to the comment cell

    I wanted to read left side cell value while reading comments from the worksheet. For example, when code reading Cell D3 comment, I also wanted to read value in the cell C3. When reading cell D4 comment, I wanted to read value in cell C4. Please find attached attached test.xls file to my first post, Sheet "Before" has input data. Sheet "After" shows expected data to be extracted from Sheet "Before". Thanks.

  4. #4
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: How to read left side cell value to the comment cell

    Do you know where all the comments are?

  5. #5
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: How to read left side cell value to the comment cell

    try this
    Please Login or Register  to view this content.
    it comes from the vba help but I cant get in to work #@#$%
    Thinking is that if you can select the cell you can find its address then the offset value

  6. #6
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: How to read left side cell value to the comment cell

    Not pretty but does the job
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    05-09-2010
    Location
    Chicago, US
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: How to read left side cell value to the comment cell

    There are lot of sheets in workbook and most of the sheets has bunch of comments. I used below code to read all the comments in workbook.

    Please Login or Register  to view this content.
    However, I need to read cell value along with comments.
    ex:
    column next to the comment cell
    2 columns over from the comment cell

    Range("E9:G17") - would this look through entire sheet.
    myCell.Comments.Shape.Visible - what this line checks for?

    Thanks.
    Last edited by gsr; 05-15-2010 at 10:58 AM.

  8. #8
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: How to read left side cell value to the comment cell

    Code tags, dude, can you add please code tags to you posts
    Last edited by pike; 05-14-2010 at 06:33 PM.

  9. #9
    Registered User
    Join Date
    05-09-2010
    Location
    Chicago, US
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: How to read left side cell value to the comment cell

    Pike,
    code you posted works fine within workbook. I'm actually reading comments from another workbook. I modified your code to read from another workbook, I got error at below line, seems like, myCell.Comments is null.
    Please Login or Register  to view this content.
    Is there something I have to change in code?

    Also, I'm getting error while closing workbook.
    Please Login or Register  to view this content.
    is it possible to read comments without opening workbook?

    code to read comments from another spreadsheet:
    ----------------------------------------------------------------------
    Please Login or Register  to view this content.
    Thank you.
    Last edited by gsr; 05-15-2010 at 01:41 PM.

  10. #10
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: How to read left side cell value to the comment cell

    Hi gsr

    The
    Please Login or Register  to view this content.
    as The syntax will away be an error unless the cell contains a Comment

  11. #11
    Registered User
    Join Date
    05-09-2010
    Location
    Chicago, US
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: How to read left side cell value to the comment cell

    pike,
    I'm getting runtime error while closing workbook. I tried adding error handling "on error resume next", however, everytime excution breaks at wbk.Close line. Seems like, workbook is closing when I stopped/end run mode. Can you please suggest how to handle this error.

    Please Login or Register  to view this content.
    Run-time error '1004'
    Application-defined or object-defined error

    Thanks.

  12. #12
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: How to read left side cell value to the comment cell

    Can you first create and collate an array of all the workbook values then
    print it to the txt file?
    other wise it not a good option as it uses errors and will err on nearly every cell

  13. #13
    Registered User
    Join Date
    05-09-2010
    Location
    Chicago, US
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: How to read left side cell value to the comment cell

    can you point me to a reference or plz post some code if possible.

    If I collate an array of all the workbook values, wouldn't be an issue while closing workbook?

    Thanks.

  14. #14
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: How to read left side cell value to the comment cell

    you could add the values to current workbook sheet then print form it?

  15. #15
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: How to read left side cell value to the comment cell

    dude,
    This works for me
    Please Login or Register  to view this content.
    Last edited by pike; 05-16-2010 at 01:31 AM. Reason: SaveChanges:=False

  16. #16
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: How to read left side cell value to the comment cell

    This works for me
    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

+ 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