LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Formula Array Macro

I am trying to create a macro for my personal workbook to use repeately on a
spreadsheet I export from one of my DB's. The spreadsheet is alway's
formatted the same, but the data table varies in size in the amount of rows.
I need to compare and flag rows based on a simple array formula. Now I am
trying to put the array into a macro to hopefully return the results of the
formla. At worst I would like the formula copied for my specified range.

The formula is - {=SUM(IF($H$6:$H$2400=$H6,IF($P$6:$P$2400=""y"",1, 0)))}

It starts on row 6 and the match value ($H6) needs to change with each row.
Column "H" may have duplicate entries, why the send IF statement is counting
how many "Y"'s are in the corresponding column "P" for each unique entry.

My first set of code which I was hoping would just return the results only
returned the value of "1" for every cell in the range -

Sub eval()

Dim rng As Range
Set rng = ActiveSheet.Range("u6")

Answer = Evaluate("=SUM(IF($H$6:$H$2400=$H6,IF($P$6:$P$2400 =""y"",1,0)))")

Range(rng, rng.Offset(0, -20).End(xlDown).Offset(0, 20)) = Answer

End Sub

The second code I tried was just to copy the array returns the value of
"False"

Sub Formu()

Dim rng As Range
Set rng = ActiveSheet.Range("u6")


Answer = Evaluate("=SUM(IF($H$6:$H$2400=$H6,IF($P$6:$P$2400 =""y"",1,0)))")

Range(rng, rng.Offset(0, -20).End(xlDown).Offset(0, 20)) = _
FormulaArray = _
"=SUM(IF($H$6:$H$2400=$H6,IF($P$6:$P$2400=""y"",1, 0)))"


End Sub

Any help would be greatly appreciated. Thanks!
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Array formula: how to join 2 ranges together to form one array? Rich_84 Excel Worksheet Functions 2 April 1st 09 06:38 PM
array formula in macro ezil Excel Programming 3 August 11th 07 12:00 PM
Writing Array formula through macro Shilps[_2_] Excel Programming 11 June 21st 07 09:32 AM
formula array in a macro Tanya Excel Programming 3 May 16th 07 11:47 AM
Tricky array formula issue - Using array formula on one cell, then autofilling down a range aspenbordr Excel Programming 0 July 27th 05 03:59 PM


All times are GMT +1. The time now is 08:37 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"