View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default Setup Cells Without Looping

Strange I still can't get it to work.

I formatted A1 with one decimal place
I formatted B1 with two decimal places
I formatted C1 with three decimal places

after I run sample1 I get:

1.0 1.00 1.000

1 1 1

after I run sample2 nothing changes !?!
--
Gary''s Student - gsnu200832


"JLGWhiz" wrote:

Maybe I didn't make enough tests, but the one I ran worked. I set A1:C1
number format to 0.00 then ran the macro and it changed the numbers in A3:C3
to 0.00 format.

"Gary''s Student" wrote:

If I enter data in A1 thru C1 and run:

Sub sample1()
Set r1 = Range("A1:C1")
Set r2 = Range("A3:C3")
r2.Value = r1.Value
End Sub

The values get correctly setup in A3 thru C3, but if I run:

Sub sample2()
Set r1 = Range("A1:C1")
Set r2 = Range("A3:C3")
r2.NumberFormat = r1.NumberFormat
End Sub

the formats do not get setup. Why?
--
Gary''s Student - gsnu2007xx