View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Calculation With A Macro

Just a note.

VBA is pretty forgiving. You can concatenate text with numbers and still end up
with text.

..Range("B" & CStr(X))
could be written as:
..Range("B" & X)

(same in the =sum() portion, too.)

I like:
..cells(x,"B")
though.

I'm guessing that VB is less forgiving?????

"Rick Rothstein (MVP - VB)" wrote:

This macro allows you to specify the worksheets (in the Array function call)
and copy the formula to the required cells on each sheet...

Sub CopyCell()
Dim X As Long
Dim Sh As Variant
For Each Sh In Array("Sheet1", "Sheet2", "Sheet3")
For X = 7 To 501
Worksheets(Sh).Range("B" & CStr(X)).Formula = _
"=SUM(E" & CStr(X) & "/" & Sh & "!$D$26)*52"
Next
Next
End Sub

Rick

"Bob" wrote in message
...
In cell V7 of my worksheet I have the following formula:

=SUM(E7/Sheet1!$D$26)*52

What I would like to do is copy this formula down to line V501 without
having to copy and paste. I also have this same formula in 7 other
worksheets
so I would also like to do the same in those as well. I am assuming I will
need some kind of loop in order to do it in the one sheet as well as the
others but do not know how to execute it.

Thanks.

Bob



Thanks.


--
Bob


--

Dave Peterson