PDA

View Full Version : Cell referencing in formula



wongsh
07-27-2016, 07:59 AM
Hi,

I am trying to write a script to input a fomula into a cell, with a known cell multiplying by an unknown cell.
The unknown cell's location varies with the length of the set of data. E.g. if there are 10 rows in the data set, the unknown cell will be on row 12, and with 15 rows data the unknown cell will be on row 17 etc. Anyone can help me on that? Thanks!


Dim Ttl As String
Range("E2").Select
Selection.End(xlDown).Select
ActiveCell.Offset(0, 2).Select
ActiveCell.Select
Ttl = ActiveCell
Range("F3").Formula = "+E3*" & Ttl

Paul_Hossler
07-27-2016, 08:18 AM
I think this is what you were looking for, or at least a start




Range("F3").Formula = "=E3*" & Range("E2").End(xlDown).Offset(0,2).Address

wongsh
07-28-2016, 09:50 AM
Yes that's exactly what I need! Thanks!!