View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Calculations using vb code?

Hi,

Because I named the sheet in the WITH statement it can go in either
including if you want a general module.

If your using it in conjunction with a userform then you need a method of
calling the code which could be a button on the userform or an event
associated with the userform.

Mike

"hoyos" wrote:

Thanks Mike,
Does that go in the sheet2 code or the userform code?

"Mike H" wrote:

Hi,

Sub addup()
Dim MSht As Variant
Set MSht = Sheets("Sheet2")
With MSht
MTot = .Range("B1") / 28 + .Range("B3")
MyOthertot = (1013 - .Range("B4")) * 28
End With
End Sub


Mike

"hoyos" wrote:

How can I the following formula into a vb code.

=SUM(Sheet2!B1/28)+Sheet2!B3
and
+SUM(1013-Sheet2!B4)*28

Any ideas?