Format Number in Header

deep6

Board Regular
Joined
Apr 20, 2004
Messages
55
Hi,

I've got a RightHeader that is referencing a number from a cell. However, sometimes that figure has 12 numbers to the right of the decimal. Is there some code that I can use that will format the number in the header so that it only goes 2 decimal places?
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

Fat Cat

Active Member
Joined
Nov 5, 2004
Messages
336
Untested, but can you use the Format command when assigning the value from the cell to the header ?

ie:

Label1.Caption = Format(Cells(4, 3).Value, "#.###") for 3 decimal places
 

Chas17

Well-known Member
Joined
Oct 16, 2002
Messages
657
Code:
Sub RtHdr()
'assumes your number for header is in range a1
'good luck, Chas Weber
    myHeader = Format(Range("a1"), "00.00")
    ActiveSheet.PageSetup.RightHeader = myHeader
End Sub

Chas
 

deep6

Board Regular
Joined
Apr 20, 2004
Messages
55
Yes I can! Only I didn't know that until you suggested it. Thank you for your help ... problem solved.
 

deep6

Board Regular
Joined
Apr 20, 2004
Messages
55
Thank you too, Chas17. I just saw your post and it too works. I'm not real good a using code to do formatting, but both of you have given me some insight.

Thanks again.
 

Forum statistics

Threads
1,171,631
Messages
5,876,552
Members
433,200
Latest member
CoolBlue_

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
Top