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 523247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:26:16+00:00 2026-05-13T08:26:16+00:00

Basically I would like to keep the existing format of an Excel cell. If

  • 0

Basically I would like to keep the existing format of an Excel cell.
If I use
ActiveCell.Value2 = “new value”;

The ActiveCell displays “new value” but loses the user defined formatting ( say red font, blue background), all formatting values goes back to Excel default format values.

Note: If you replace a cell value using Excel, Excel keeps the user’s format.
When recording this action as a macro, Excel uses the property FormulaR1C1 but according to MSDN this a property used for macros.

  • 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-05-13T08:26:17+00:00Added an answer on May 13, 2026 at 8:26 am

    If I use ActiveCell.Value2 = “new value”
    the ActiveCell displays “new value” but loses the user defined formatting

    No, it does not, I just tested it (with Excel 2003). Opened a new empty document, formatted a column with some colors and user defined number format and and entered

    ActiveCell.Value2="1"
    

    in the immediate Window of the VBA editor. The existing format is kept intact. So if you have another scenario to deal with (where the format gets lost), please describe it in detail.

    EDIT: if this behaviour is really different in VSTO, as a workaround, you can try to save the relevant format information of the ActiveCell before changing the value, for example

    fci = ActiveCell.Range.Font.ColorIndex
    ici = ActiveCell.Range.Interior.ColorIndex
    pat = ActiveCell.Range.Interior.Pattern
    nf = ActiveCell.Range.NumberFormat
    

    then change the value

    ActiveCell.Value2 = "new value"
    

    and afterwards reassign the format info again

    ActiveCell.Range.Font.ColorIndex = fci
    ActiveCell.Range.Interior.ColorIndex = ici
    ActiveCell.Range.Interior.Pattern = pat
    ActiveCell.Range.NumberFormat = nf
    

    (but beware, this is ‘air code’).

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

Sidebar

Related Questions

In this, I would see Readme, but the value would be set to 1
I would like to create an ASP.Net page without all the codebehind and designer
I have three tables that I would like to query: Streams, Entries, and FieldInstances.
I am trying to take an existing vector and repeat each element of it
I have a situation like below in which I have some problem in freeing
I have some basic questions about core data (which I am new to) and
Each product a product_date_added which is a Date field contained the date it was
I'm about to revisit an application that I've been trying to get off the
I need to be able to manage some torrent downloads on my server with
I'm slightly overwhelmed by how many ways there are of processing XML in .NET..

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.