Format Active Cells

S.H.A.D.O.

Well-known Member
Joined
Sep 6, 2005
Messages
1,915
Hi everyone,

How can I format the following please :-

Code:
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.
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Lewiy

Well-known Member
Joined
Jan 5, 2007
Messages
4,284
Is this what you mean?
Code:
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 = "#"
    .Offset(1, 0).Select
End With
 
Upvote 0

S.H.A.D.O.

Well-known Member
Joined
Sep 6, 2005
Messages
1,915
Thanks Lewiy, that is EXACTLY what I was after.
What about if I wanted to format ...

Code:
.Offset(0, 0).Value = "For 1 - " & POOL & " there are " & tly & " different set of " &  cmb & " numbers. "
... as "#,##0" for the tly output please?.

Thanks in Advance.
 
Upvote 0

Forum statistics

Threads
1,191,038
Messages
5,984,279
Members
439,881
Latest member
Amitoj95

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top