View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Increase & Decrease Decimal Place

Give this macro a try...

Sub DPshiftup()
With Range("Q16")
If .NumberFormat = "0" Or .NumberFormat = "General" Then
.NumberFormat = "0.0"
Else
.NumberFormat = .NumberFormat & "0"
.NumberFormat = Replace(.NumberFormat, "0000", "000 0")
End If
End With
End Sub

Although you didn't ask, I guess you could use something like this to remove
zeroes from the number format...

Sub DPshiftdown()
With Range("Q16")
If .NumberFormat = "0" Or .NumberFormat = "General" Then Exit Sub
.NumberFormat = Trim(Left(.NumberFormat, Len(.NumberFormat) - 1))
If Right(.NumberFormat, 1)= "." Then .NumberFormat = Val(.NumberFormat)
End With
End Sub

--
Rick (MVP - Excel)


"Aaron" wrote in message
...
Hi,

I have a macro tied to a button called UP

Sub DPshiftup()
'
' DPshiftup Macro
ActiveSheet.Unprotect
With Range("Q16")
If .NumberFormat = "0" Or .NumberFormat = "General" Then

.NumberFormat = "0.0"
Else
.NumberFormat = .NumberFormat & "0"
End If
End With
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True
End Sub

Which is fine, but I need it to continue going up as long as I hit the
"UP" button. IE 0 to 0.0 to 0.00 to 0.000 to 0.000 0 to 0.000 00 to a
maximum of 0.000 000. I also need the cell to be formatted so that
after every 3rd decimal place there is a space before the other
decimal place holders are applied.

I also need one to shift down also starting at a maximum of 0.000 000
to 0.000 00 to 0.000 0 etc down to 0.

TIA

Aaron.