View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Bill Martin[_2_] Bill Martin[_2_] is offline
external usenet poster
 
Posts: 105
Default Enter Formula via VBA

Bobby wrote:
Greetings
I have a file that is imported daily and it varies as to the number of lines
in the file each day. Using a macro I woud like find the next available row
and enter the following formula in ColH:ColAE (24 Cols)
=SUMPRODUCT(--($F$3:$F$66="Cat"),--($G$3:$G$66="Bird"),--
($C$3:$C$66<"Black"),--($C$3:$C$66<"White"),H3:H66)
The example file had 66 rows of data and this is the part that could change
each day.
Thanks

--------------------

Tom gave you the "right" answer. Here's a cheezier one which is perhaps easier
to understand:

dim LastRow as Long
dim ColIndex as Long
LastRow = Range("H1").end(xlDown).row
for ColIndex = 8 to 31
cells(LastRow + 1,ColIndex) = "=SUMPRODUCT(...etc...."
next ColIndex

Bill (Small change edited into code)