+ Reply to Thread
Results 1 to 9 of 9

Applying code to the 'selected' cells only

  1. #1
    Registered User
    Join Date
    12-23-2012
    Location
    Glasgow, Scotland
    MS-Off Ver
    Office 365 for Mac
    Posts
    23

    Applying code to the 'selected' cells only

    Hello all,

    I found this handy piece of code which formats all comments on the active sheet in my workbook. However, I'd like to try to modify it in order that it only applies the formatting to the comments in the cells I had selected:

    [I]
    Please Login or Register  to view this content.
    What I'm trying to achieve ultimately is two different formats for different types of comment so I'd have two separate codes but I'm really struggling with only applying to the selected cells only.

    Being a VBA novice, any assistance would be greatly appreciated!

    Many thanks in advance ....
    Last edited by alansidman; 11-13-2013 at 03:23 PM. Reason: code tags added

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Applying code to the 'selected' cells only

    Change Activesheet to Selection ...

  3. #3
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2403 Win 11 Home 64 Bit
    Posts
    23,810

    Re: Applying code to the 'selected' cells only

    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



    (I have added the code tags for you. Please observe our rules in the future.)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  4. #4
    Registered User
    Join Date
    12-23-2012
    Location
    Glasgow, Scotland
    MS-Off Ver
    Office 365 for Mac
    Posts
    23

    Re: Applying code to the 'selected' cells only

    Quote Originally Posted by cytop View Post
    Change Activesheet to Selection ...
    I did already try this but I get runtime error '438 object doesn't support this property or method'

    Quote Originally Posted by alansidman View Post
    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
    Many apologies, I'll be sure to comply in future .... thank you
    Last edited by CXsjr; 11-13-2013 at 03:32 PM.

  5. #5
    Forum Contributor
    Join Date
    03-21-2013
    Location
    Corvallis, OR
    MS-Off Ver
    Excel 2010
    Posts
    174

    Re: Applying code to the 'selected' cells only

    Try this code:
    Please Login or Register  to view this content.
    If I helped, please click on Add Reputation.

  6. #6
    Registered User
    Join Date
    12-23-2012
    Location
    Glasgow, Scotland
    MS-Off Ver
    Office 365 for Mac
    Posts
    23

    Re: Applying code to the 'selected' cells only

    Quote Originally Posted by bmxfreedom View Post
    Try this code:
    Worked a treat; I've been trying to work this out all afternoon .... much kudos to you for finally solving my dilemma, thank you!

  7. #7
    Forum Contributor
    Join Date
    03-21-2013
    Location
    Corvallis, OR
    MS-Off Ver
    Excel 2010
    Posts
    174

    Re: Applying code to the 'selected' cells only

    Excellent. Glad I could help.

  8. #8
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Applying code to the 'selected' cells only

    Based on your last post in this thread, its apparent that you are satisfied with the solution(s) you've received and have solved your question, but you haven't marked your thread as "SOLVED". I will do it for you this time.

    In future, to mark your thread as Solved, you can do the following -
    Select Thread Tools-> Mark thread as Solved.

    Incase your issue is not solved, you can undo it as follows -
    Select Thread Tools-> Mark thread as Unsolved.

    Also, since you are relatively new to the forum, i would like to inform you that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post which helped you. This adds to the reputation of the person who has taken the time to help you.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  9. #9
    Forum Contributor
    Join Date
    03-21-2013
    Location
    Corvallis, OR
    MS-Off Ver
    Excel 2010
    Posts
    174

    Re: Applying code to the 'selected' cells only

    Woops, meant to post this on another post. Doh.

+ 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. Applying code to specific cells when using worksheet_change?
    By Bevmachine in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-13-2013, 11:37 AM
  2. [SOLVED] Applying code only to visible cells
    By pezalmendra in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-08-2012, 11:07 AM
  3. Applying a formula to multiple selected cells
    By Prokasaurus in forum Excel General
    Replies: 1
    Last Post: 03-26-2012, 04:06 AM
  4. applying macro code to a range of cells
    By just-gal in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-31-2009, 02:26 PM
  5. applying changes to multiple selected worksheets
    By bimmerman in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-26-2007, 05:52 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