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

  • Home
  • SEARCH
  • 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 8300459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:34:07+00:00 2026-06-08T16:34:07+00:00

I want to add conditional formatting on a range depending on some condition. I

  • 0

I want to add conditional formatting on a range depending on some condition.

I want to to format the Color, Size , Bold etc properties. I am able to modify Color, Bold properties but when i try to modify Size property it throws an exception “Unable to set the Size property of the Font class”.

Can anyone help how can i set the Size property of Conditional Formatting object.

It is not possible to set subscript or superscript property also.

Note : These properties are not Read-Only also.

            FormatCondition format =(FormatCondition)( targetSheet.get_Range("A1:A10",
            Type.Missing).FormatConditions.Add(XlFormatConditionType.xlExpression, XlFormatConditionOperator.xlGreater,
            "100", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing));

            format.Font.Bold = true;
            format.Font.Color = 0x000000FF;
            format.Font.Size = 14;
            format.Font.Subscript = true;

To make clear the actual usecase lets take an example where i have data of 10*10 in excel. This 10*10 is a single Range with its own format. For E.g A1 to J10. Now if i select any cell of this range then its corresponding Rows and Columns should get a Conditional Formating and it would have its own formats. This includes different fill color, different font size, change in border etc. Such as if i select cell D4 then Range A4:J4 and D1:D10 will have conditional formats applied.This can be done by applying formats on these both range and choosing type as Expression and its formula as true. Now if i select any other cell then the formats of A4:J4 and D1:D10 cells should be reverted back and the rows and colummn for the currently selected cell should be highlighted.

We can change the format such as only the Color or pattern. But its not possible to set the Size. Can anyone explain me why is it so.
Changing the size from User Interface is possible. i.e using the Format option of conditional formatting. Using that the font size,color etc of the cells which satisfies the condition can be changed.

Things which are possible from UI should be possible from code also.

Have share an image to get a view: https://i.stack.imgur.com/0g1qq.jpg

  • 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-08T16:34:09+00:00Added an answer on June 8, 2026 at 4:34 pm

    Try the following (you can change the color values and add additional properties for font size, color, etc.):

    Dim fontSize As Variant
    Dim fontType As Variant
    Dim fontBold As Variant
    Dim cellIn As Variant
    
    Sub setVars()
    
        With Range("A1")
            fontSize = .Font.Size
            fontType = .Font.Name
            fontBold = .Font.Bold
            cellIn = .Interior.Color
        End With
    
    
    End Sub
    
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    
        Application.ScreenUpdating = False
        Application.EnableEvents = False
    
        Dim r As Range
        Set r = Range("A1:J10")
    
        With r
            .Font.Size = fontSize
            .Font.Name = fontType
            .Font.Bold = fontBold
            .Interior.Color = cellIn
        End With
    
        With r.Rows(Target.Row)
            .Interior.ColorIndex = 5
            .Font.Bold = True
        End With
    
        With r.Columns(Target.Column)
            .Interior.ColorIndex = 5
            .Font.Bold = True
        End With
    
        Application.ScreenUpdating = True
        Application.EnableEvents = True
    
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have added a Format Condition on a range with some formatting using the
I've got a query below. I want to add a condition that if the
Hi I want to add image in table cell according to condition in table.
I have a website built with ASP.NET (3.5) and want add some level of
Suppose I want to add a runtime conditional to a Makefile generated by Automake.
Depending of some flag I want to use certain component in my mxml. There
i am using jqGrid treegrid and i want to format the back color of
I want to add conditional logic functionality to cforms plugin. The existing contact form
I want add UIGestureRecognizerDelegate to UIWebView,but failed. if [self.view addsubView:webView]; So UIWebView is ok,but
I want add new Feed item on entity persist and update. I write this

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.