Consulting

Results 1 to 2 of 2

Thread: Automatically Change Colour of Table Cell to Match Colour of Another Cell

  1. #1

    Automatically Change Colour of Table Cell to Match Colour of Another Cell

    Hello,

    I'm trying to set the shading of a specific cell in a table to match that of the cell below. The cell below may be any colour so I can't specifically state the colour in the code.

    I was thinking something along the lines of:

    Dim LowerCellColour As Shading
    LowerCellColour = ActiveDocument.Tables(1).Cell(5, 1).Shading

    ActiveDocument.Tables(1).Cell(4, 1).Shading = LowerCellColour

    Or something like that, but it doesn't work

    Any advice?

  2. #2
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,337
    Location
    Sub ScratchMacro()
    'A basic Word macro coded by Greg Maxey
      ActiveDocument.Tables(1).Cell(4, 1).Shading.BackgroundPatternColor = _
        ActiveDocument.Tables(1).Cell(5, 1).Shading.BackgroundPatternColor
    End Sub
    Greg

    Visit my website: http://gregmaxey.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •