Another Simple Question

tphillips

Board Regular
Joined
Jan 28, 2003
Messages
76
How do I format a cell name in code to drop the digits after a decimal. For example, I want the value of A1 to display with no decimals. But I need to do it in code. Thanks
 

Some videos you may like

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

lenze

Legend
Joined
Feb 18, 2002
Messages
13,690
Why do you need code?

Format>Cells>Number Tab Custom Type = ###

This will round the number to the nearest whole number. If you always want to round down, see the ROUNDDOWN funtion. There are also other funtions the work as well or better for this.

lenze
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
55,381
Office Version
  1. 365
Platform
  1. Windows
Code:
    MsgBox Format(Range("A1"), "0")
Of course, you can also set it equal to a variable instead of displaying it in a Message Box.
 

Watch MrExcel Video

Forum statistics

Threads
1,118,112
Messages
5,570,259
Members
412,314
Latest member
yazanwael
Top