Thread: Number Format
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 Number Format

It would have been better to post your message back at the original thread
where its content would have been in context. As for your your question, the
'g' seems to have meaning to the NumberFormat, although I'm not sure what it
is at the moment (and I'm about to go to sleep for the evening, so I won't
look for it until morning here), but the 'k' doesn't. Try using " k\g". Here
are your two macros with that change included...

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

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

--
Rick (MVP - Excel)


"Aaron" wrote in message
...
Hi,

Im using
.NumberFormat & " \g" sucessfully, but I cant use .NumberFormat & "
\kg" as excel says it cant set the number format.

Why should it care about a text inside brackets or is it limited to
just one text character? How can I make this work?

TIA

Aaron.