Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7860277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:13:23+00:00 2026-06-02T22:13:23+00:00

I created a conditional formatting to change the color based on value compare for

  • 0

I created a conditional formatting to change the color based on value compare for one cell, but I don’t know how to apply this formatting for the whole column and even other columns? (do I have to use for loop to set the formatting for all the cells?)

'add conditionalFormating for one cell.
 Set rngCell = Cells(6, 7)
 Set objCF = rngCell.FormatConditions.Add _
            (Type:=xlExpression, _
            Formula1:="=" & rngCell.Address & " > " & rngCell.offset(, -3).Address)
'set formats for new CF

With objCF
    .Font.ColorIndex = 26
    .Interior.ColorIndex = 19
End With

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T22:13:27+00:00Added an answer on June 2, 2026 at 10:13 pm

    Unfortunately, Excel 2007/2010 don’t have as extensive a macro record function as earlier versions

    If you are referencing other cells when applying conditional formatting, a good method is to apply it to one cell (which you know how to do), and then copy the formatting to the rest of the column; if you are filling down a column, this should not cause you to lose other cell formats you may wish to keep

    So I would start your code with

    rngCell.FormatConditions.Delete
    

    Then once the format is added, you can simply use:

    rngCell.Copy
    rngOut.PasteSpecial xlPasteFormats
    

    , where rngOut is defined as starting with rngCell and filling down to the last row in the table

    To apply to other columns, you would probably need a different formula as there are different offsets. To minimise the required code, you could always manually add the full set of formats/conditional formats you want to a hidden row just above the table’s headers. Then you can copy all of these to your table using code of the form…

    Range("A1:J1").Copy
    Range("A3:J100").PasteSpecial xlPasteFormats
    

    …if we assume your header gets pushed down to row 2 when you add the formatted row in row 1

    Although I have referred to cell addresses in the above example, I would always recommend referring to range names and using cells notation e.g. Range(“A1”) is Cells(1, 1). The use of range names to define columns in tables is covered in more detail in this expert Excel video. The benefits are immense…if your header row is defined with a range name, you can insert a new row above your table without having to re-write any code

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create conditional comments in XSLT. But when I use this: <!--
WPF makes it very easy to create conditional formatting rules at design time based
Has anyone been able to get the conditional formatting for work based on dates?
I created the following conditional regex which seems to work at http://gskinner.com/RegExr/ but doesn't
It is possible to create a constant like this: http://haacked.com/archive/2007/09/16/conditional-compilation-constants-and-asp.net.aspx <%@ Page CompilerOptions=/d:QUUX %>
Im facing following problem I have created mentioned condition, but when I choose y
I'm having problems using conditional ORDER BYs. I want to do something like this
Hi I am getting the the following error from valgrind. Conditional move based on
I just saw this block of code on the Wikipedia article on conditional operators:
I am just learning MVC and I've created a form but I would like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.