ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Pasting a worksheet function in VBA. (https://www.excelbanter.com/excel-programming/306283-pasting-worksheet-function-vba.html)

Jako[_64_]

Pasting a worksheet function in VBA.
 
Could someone please tell me how to paste a Worksheet Function into
cell in VBA.

For example this formula.

=SUM(IF(FREQUENCY(UNRng,UNRng)0,1))

Also for data running form "A2" down to the last entry in the column
need to set this range as UNRng. Please also tell me how i can achiev
this in VBA.

The data is on a Workbook called "Closures" and the worksheet i
"Sheet1".

Thanks in advance

--
Message posted from http://www.ExcelForum.com


Tom Ogilvy

Pasting a worksheet function in VBA.
 
set rng = Range(Cells(2,1),Cells(2,1).End(xldown))
sform = " =SUM(IF(FREQUENCY(UNRng,UNRng)0,1))"
Range("C9").FormulaArray = application.Substitute(sform,"UNRng",rng.Address)

--
Regards,
Tom Ogilvy

"Jako " wrote in message
...
Could someone please tell me how to paste a Worksheet Function into a
cell in VBA.

For example this formula.

=SUM(IF(FREQUENCY(UNRng,UNRng)0,1))

Also for data running form "A2" down to the last entry in the column i
need to set this range as UNRng. Please also tell me how i can achieve
this in VBA.

The data is on a Workbook called "Closures" and the worksheet is
"Sheet1".

Thanks in advance.


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 12:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com