+ Reply to Thread
Results 1 to 7 of 7

Add COMMENT TEXT to Selection

  1. #1
    Forum Contributor
    Join Date
    09-05-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    209

    Add COMMENT TEXT to Selection

    I want to add comments to certain name in column " C ", here's what I have so far. Please help me, what am I missing or doing wrong

    Please Login or Register  to view this content.
    Attached Images Attached Images

  2. #2
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,844

    Re: Add COMMENT TEXT to Selection

    I didn't pinpoint why it didn't work, I just shuffled the code around until it worked.
    The End(xlDown) will stop at the first empty cell in the column, maybe that was your problem. I assume you put the code in the form and not in an ordinary module, otherwise that will not work.
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    09-05-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    209

    Re: Add COMMENT TEXT to Selection

    I can't seem to test yours. noting shows up or if I added text, the text in column c disappear.
    I've uploaded the sample i want to use.
    Oh as for the x1down, I took it off and used (c3:c800) which is the end of my sheet.
    Attachment 182785

  4. #4
    Forum Contributor
    Join Date
    09-05-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    209

    Re: Add COMMENT TEXT to Selection

    Ok, I added your code. It did what I want it to do and more. It delete everthing else in that column instead of leaving it as is.

    Also, trying to understand how this works. Why we need the trn as range when we have Tmember as range already.
    why do we use Debug.Print for textbox1 when textbox2 doesn't have one?

  5. #5
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,844

    Re: Add COMMENT TEXT to Selection

    Debug.Print is a tool that I use to check that parts of the code do what I expect it to, I just forgot to delete it. It just prints to the Immediate window which is available in the VB editor. Feel free to delete that line.

    The extra range Trng is just an intermediate step I added, also to make it easier to check the code. You could of course move that line to the start of the loop instead and skip the Trng but if I were you I would just leave it as it is.

    The line below is what is deleting your cells. Since it was part of the code you posted I assumed that was what you wanted.
    Just delete these two lines to solve that problem.
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    09-05-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    209

    Re: Add COMMENT TEXT to Selection

    I guess, my code was missing the .value.
    My previous question about textbox1 and I didn't have to use .value at the end.
    I wonder what was the different of using and not using.
    Thanks everything works.
    I will edit "solved" If above question get answer or 3 days over due, thanks Admin.

  7. #7
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,844

    Re: Add COMMENT TEXT to Selection

    I don't think there is a difference between using .Value and not using it.
    Range("A1").Value=888 means the same as Range("A1")=888.
    When you skip the .value Excel assumes that's what you want anyway.
    However, Value is just one of many properties of the object range. I think it's more correct and makes the code easier to read if I use .Value.

    I'm pretty sure the same reasoning can be applied to the textbox object.

+ 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