View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Udo Udo is offline
external usenet poster
 
Posts: 48
Default writing formulas in VB - referring to the values contained in cell

Hi Josie,

given your r1 through r4 are variables, the following should work:
Dim R1 As String
Dim R2 As String
Dim R3 As String
Dim R4 As String
Dim per1 As String

R1 = "B4"
R2 = "H4"
R3 = "B8"
R4 = "H5"

per1 = "=sum(" & R3 & ":" & R4 & ")/(sum(" & R1 & ":" & R2 & ")/100)"
ActiveCell.Formula = per1

Good luck
Udo