View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
OssieMac OssieMac is offline
external usenet poster
 
Posts: 2,510
Default Formatting Active Cells

Hi Paul,

I'm not sure what you mean by accept 1000's and no decimals. I have assumed
you mean use the comma to separate as per 1,000. However, here is an example
of formatting integrated into you code.

If the formats are not exactly as you want then simply record a macro as you
set the required formats and you will be able to get the syntax to edit the
example.

There is no general format with no decimals. General format will include
decimals if they are there or leave them out if not there.

Worksheets("Test").Select
With ActiveCell
.Offset(1, 0).Value = cmb & " If " & pik
.Offset(1, 0).HorizontalAlignment = xlRight
.Offset(1, 1).Value = Tested
.Offset(1, 1).NumberFormat = "#,##0"
.Offset(1, 2).Value = tly
.Offset(1, 2).NumberFormat = "#,##0"
.Offset(1, 3).Value = 100 / Tested * tly
.Offset(1, 3).NumberFormat = "0.00000"
.Offset(1, 4).Value = Tested - tly
.Offset(1, 4).NumberFormat = "#,##0"
.Offset(1, 5).Value = (100 / Tested) * (Tested - tly)
.Offset(1, 5).NumberFormat = "0.00000"
.Offset(1, 6).Value = tly + Tested - tly
.Offset(1, 6).NumberFormat = "#,##0"
.Offset(1, 7).Value = (100 / Tested * tly) + ((100 / Tested) * (Tested -
tly))
.Offset(1, 7).NumberFormat = "General"
.Offset(1, 0).Select
End With

Regards,

OssieMac



"Paul Black" wrote:

Hi everyone,

How can I format the following please :-

Worksheets("Test").Select
With ActiveCell
.Offset(1, 0).Value = cmb & " If " & pik <--- Format Right
.Offset(1, 1).Value = Tested <--- Accept Thousands & NO
Decimal Places
.Offset(1, 2).Value = tly <--- Accept Thousands & NO Decimal
Places
.Offset(1, 3).Value = 100 / Tested * tly <--- 5 Decimal Places
.Offset(1, 4).Value = Tested - tly <--- Accept Thousands & NO
Decimal Places
.Offset(1, 5).Value = (100 / Tested) * (Tested - tly) <--- 5
Decimal Places
.Offset(1, 6).Value = tly + Tested - tly <--- Accept
Thousands & NO Decimal Places
.Offset(1, 7).Value = (100 / Tested * tly) + ((100 / Tested) *
(Tested - tly)) <--- General & NO Decimal Places
.Offset(1, 0).Select
End With

Thanks in Advance.
All the Best.
Paul