Storing and formatting is single operation

TheGREATrandino

New Member
Joined
Sep 9, 2020
Messages
15
Office Version
  1. 365
Platform
  1. Windows
Is it possible to store and format a value to a cell in a nested statement in excel vba?
For example,
Range("A2").value = 123445.34
range("A2").NumberFormat="#,##0.00"
both statements work and produce the desired results. How do you do something like Range("A2").value = 123445.34, format "#,##0.00"
Is it "better" to set the formatting in VBA or through the GUI on the sheet?

TIA
Randino
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
figured it out!!!!!
Is it bad to answer your own post?

Range("A2").Value = 123445.34
Range("A2").Value = Format(Range("A2"), "#,##0.00")
Format is a Function and requires a number or an expression (Range("A2")) is this example, and a formatting "template" ("#,##0.00)
 
Upvote 0
Solution
Is it bad to answer your own post?
Not at all.
As matter as fact, we encourage it. That way if someone else down the road has the same issue/question, and find this thread, they can see what the solution is.
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,252
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top