Results 1 to 9 of 9

Applying code to the 'selected' cells only

Threaded View

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

    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:

    Sub comments_format()
        Dim MyComments As Comment
        Dim lArea As Long
        For Each MyComments In ActiveSheet.Comments
        With MyComments
        .Shape.AutoShapeType = msoShapeRoundedRectangle
        .Shape.TextFrame.Characters.Font.Name = "Calibri"
        .Shape.TextFrame.Characters.Font.Size = 11
        .Shape.TextFrame.Characters.Font.ColorIndex = 2
        .Shape.Line.ForeColor.RGB = RGB(0, 0, 0)
        .Shape.Line.BackColor.RGB = RGB(255, 255, 255)
        .Shape.Fill.Visible = msoTrue
        .Shape.Fill.ForeColor.RGB = RGB(255, 0, 0)
        End With
        Next
    End Sub
    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

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