You'll still need to pick out one of the columns that can define where that last
used row is.
LastRow = .Cells(.Rows.Count, "X").End(xlUp).Row
And you'll have to adjust this to match the column that you're putting the
formula. In fact, I'd change it to something like:
Option Explicit
Sub testme()
Dim LastRow As Long
dim FirstCol as Long
dim SecondCol as long
dim FormCol as long
with worksheets("Sheet1")
firstcol = .range("e1").column 'I used column 5 (E)
SecondCol = .range("Z1").column 'I used column 26 (Z)
FormCol = .range("AZ1").column 'I used column 52 (AZ)
'using the first column to get the longest row
Lastrow = .cells(.rows.count,firstcol).end(xlup).row
.range(.cells(1,formcol),.cells(lastrow,formcol)).formula _
= "=" & .cells(1,firstcol).address(0,0) _
& "-" & .cells(1,secondcol).address(0,0)
end with
end sub
vumian wrote:
>
> ths very, but i take extend my thinks following :
>
> if they are 2 cols random, not next to each other above.
> how to do it, pls
>
> --
> vumian
> ------------------------------------------------------------------------
> vumian's Profile: http://www.excelforum.com/member.php...o&userid=36494
> View this thread: http://www.excelforum.com/showthread...hreadid=563001
--
Dave Peterson
Bookmarks