View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Formating problem

I'm not sure you you can put anything in a cell if you don't know where it
should go.

But if it's going in the activecell (say), you could use:

with activecell
.numberformat = "mm/dd/yyyy hh:mm:ss"
.value = now
.HorizontalAlignment = xlCenter
'or????
.HorizontalAlignment = xlGeneral
end with

I can think of a couple of things that could cause the date to be left
justified.

The cell could be formatted as text or it could actually have the horizontal
alignment set to left justify.

You may want to look at all the formatting options that you care about. Then
include the code to set them the way you like--including the columnwidth????




Nils Titley wrote:

Dave,

I still have a problem. Okay so I formatted the numbers now I am need to
center or right justify a column when I don't know the range. When I was
printing the date in a column it automaticaly seems to right justify. The
user in South Africa asked if I would just have the date. It appears that
the date for them includes the time. So I formated the date to be "ddmmyy"
which is common for them. When I did that the date became left justified in
the column.

I am creating the worksheet that accepts the data.

How do I do this. I serached the help...

Thanks, you are helping me a lot.

"Dave Peterson" wrote:

Sure.

Just format the column the way you want.

Worksheets("sheetnamehere").range("m1,x1").entirec olumn.numberformat = "0.00"

You could even format the ranges manually and forget about doing it in code.



Nils Titley wrote:

That makes good sense but can't I just change the format for a column which
would apply to all inputs. I have 13 columns I am using 1 date, 3 times, 7
integers and 2 that need the 1 decimal.

In you replay what does ("x99") actually tell the range?

Thanks

"Dave Peterson" wrote:

Are you plopping the value into a cell on a worksheet?

If yes, then make sure you change the numberformat of the cell:

with activesheet.range("x99")
.numberformat = "0.0"
.value = Format((BeatMetersTotal(MyNum) / BinTotal(MyNum)), "0.0")
End with

If you're not doing putting the value in a cell, then I think you'll have to
explain more.

Nils Titley wrote:

I am using the following

Now
A) Format((BeatMetersTotal(MyNum) / BinTotal(MyNum)), "0.0")
Previously
B) Format((BeatMetersTotal(MyNum) / BinTotal(MyNum)), "0.00")

I want my output to show one decimal place. I get the following with the
above format: A) 2 B) 1.98. How do I force it so I get what I want. I am
using the same data to generate the same report.

Thanks

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson