NumberFormat

F

Forrest

I want to conditionally format the cell. Positive results
should say $10gain and negative results say $10loss.
Creating a custom number format within Excel2002 works
fine, but copying into VBA creates an error. The following
is my vba code without the text.

With xlWs
.Cells(6, 2).NumberFormat = "$#,##0_);($#,##0)"
End With

Help?
 
T

Tushar Mehta

What happens if you turn on the macro recorder, create the custom
format and turn off the recorder? Doesn't XL give you the necessary
syntax?

--
Regards,

Tushar Mehta, MS MVP -- Excel
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
 
F

Forrest

No. The macro recorder when adding text gives me something like this: $#,##0.0"m
When I incorporate that into my code I get: "Compile error: Expected : end of statement" The parenthesis are causing the error?
 
T

Tushar Mehta

Don't know what to write. Works for me. The macro recorder generates
the correct number of quotes

"_($* #,##0_)"" gain"";_($* (#,##0)"" loss"";_($* ""-""_);_(@_)"


--
Regards,

Tushar Mehta, MS MVP -- Excel
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
 
F

Forrest

Tushar, thank-you much your syntax worked it had to do
with the number of quotes.

Forrest
-----Original Message-----
Don't know what to write. Works for me. The macro recorder generates
the correct number of quotes

"_($* #,##0_)"" gain"";_($* (#,##0)"" loss"";_($* ""- ""_);_(@_)"


--
Regards,

Tushar Mehta, MS MVP -- Excel
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

(e-mail address removed) says...
error: Expected : end of statement" The parenthesis are
causing the error?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top