+ Reply to Thread
Results 1 to 5 of 5

VBA to Change Formats of Cells Within a Selection

  1. #1
    Registered User
    Join Date
    12-20-2012
    Location
    Washington DC
    MS-Off Ver
    Excel 2010
    Posts
    12

    VBA to Change Formats of Cells Within a Selection

    Hi,

    I've spent a bit of time searching for this but haven't been able to find what I need (perhaps it's too specific). I create summary tables every day (of varying rows and columns) and they all need to be formatted a particular way. I'm wondering if there's a way to select the table and format everything how it needs to be formatted. The challenge I'm facing is that the top row needs to be filled in a particular color and have a slightly different border than the table contents.

    I'm not sure if there's a way to identify and temporarily store the cell references of a selection, format the entire table, then use some sort of operation to format just the header row? I don't know, I'm sure someone has a much more elegant solution. It's not a huge problem but it would be nice if I could do it with a button.

    Any help is greatly appreciated!
    Kevin

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: VBA to Change Formats of Cells Within a Selection

    Kevin

    Perhaps something like this.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    12-20-2012
    Location
    Washington DC
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: VBA to Change Formats of Cells Within a Selection

    Thanks for the suggestion but I don't think I was very clear about what I was looking for. After tinkering around with it for a while, I think I got it. It may not be the cleanest, but it appears to work.

    When I select a range, I have code that formats the entire selection, then the following lines just select the top row, and then I have formatting code below that applies the format just to that row. Again, probably not the cleanest but it looks like it works.

    a = ActiveCell.Row
    b = ActiveCell.Column
    c = Selection.Columns.Count
    Range(Cells(a, b), Cells(a, b + c - 1)).Select

    Thanks!
    Kevin

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: VBA to Change Formats of Cells Within a Selection

    Kevin

    If you want to apply formatting to the current selection, with the first row being a different format you could use something like this.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    12-20-2012
    Location
    Washington DC
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: VBA to Change Formats of Cells Within a Selection

    I knew there was a better way, thanks so much!

+ 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. [SOLVED] Make a drop down selection change other cells
    By Lviolist in forum Excel General
    Replies: 3
    Last Post: 08-18-2013, 09:14 AM
  2. How to change cells in Selection to values
    By alexxgalaxy in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 09-17-2011, 01:51 PM
  3. Replies: 0
    Last Post: 01-21-2006, 11:10 AM
  4. [SOLVED] Cannot change formats of cells???
    By ChrisA in forum Excel General
    Replies: 2
    Last Post: 06-27-2005, 01:05 PM
  5. macro to change cells on change of selection
    By scottwilsonx in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 01-13-2005, 04:14 AM

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