Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Programmatically add a Formula in a worksheet?
Hi,
My workbook has 2 worksheets: WSA & WSB. WSB gives stats on numbers shown in WSA. In WSB, in cell B2, there is a function that counts elements from WSA: =COUNTIF('WSA'!D2:D35000,"<N/A") Still in WSB, using a commandButton, I'd like to modify the above formula programmatically. I've been trying using: ActiveWorkbook.Sheets("WSB").Cells(1, 2).Formula = "=COUNTIF('WSA'! D2:D36000,"<N/A")' but no luck. However, if I put something simple that such as: .Formula = "=sum(D3:D10)", it works. So I suspect the worksheet referencing is in cause here. Thanks for your help |
#2
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Programmatically add a Formula in a worksheet?
Hi,
The problem is the quotes, note how i've doubled the internal quotes up around the NA ActiveWorkbook.Sheets("WSB").Cells(1, 2).Formula = "=COUNTIF('WSA'!D2:D36000,""<N/A"")" Mike "circuit_breaker" wrote: Hi, My workbook has 2 worksheets: WSA & WSB. WSB gives stats on numbers shown in WSA. In WSB, in cell B2, there is a function that counts elements from WSA: =COUNTIF('WSA'!D2:D35000,"<N/A") Still in WSB, using a commandButton, I'd like to modify the above formula programmatically. I've been trying using: ActiveWorkbook.Sheets("WSB").Cells(1, 2).Formula = "=COUNTIF('WSA'! D2:D36000,"<N/A")' but no luck. However, if I put something simple that such as: .Formula = "=sum(D3:D10)", it works. So I suspect the worksheet referencing is in cause here. Thanks for your help |
#3
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Programmatically add a Formula in a worksheet?
Sub doformula()
ActiveWorkbook.Sheets("wsb").Cells(1, 2).Formula = _ "=COUNTIF('wsa'!D2:D36000,""<N/A"")" End Sub -- Don Guillett Microsoft MVP Excel SalesAid Software "circuit_breaker" wrote in message ... Hi, My workbook has 2 worksheets: WSA & WSB. WSB gives stats on numbers shown in WSA. In WSB, in cell B2, there is a function that counts elements from WSA: =COUNTIF('WSA'!D2:D35000,"<N/A") Still in WSB, using a commandButton, I'd like to modify the above formula programmatically. I've been trying using: ActiveWorkbook.Sheets("WSB").Cells(1, 2).Formula = "=COUNTIF('WSA'! D2:D36000,"<N/A")' but no luck. However, if I put something simple that such as: .Formula = "=sum(D3:D10)", it works. So I suspect the worksheet referencing is in cause here. Thanks for your help |
#4
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Programmatically add a Formula in a worksheet?
That simple! It works, thanks very much.
On Jul 6, 9:17*am, circuit_breaker wrote: Hi, My workbook has 2 worksheets: WSA & WSB. *WSB gives stats on numbers shown in WSA. *In WSB, in cell B2, there is a function that counts elements from WSA: =COUNTIF('WSA'!D2:D35000,"<N/A") Still in WSB, using a commandButton, I'd like to modify the above formula programmatically. *I've been trying using: ActiveWorkbook.Sheets("WSB").Cells(1, 2).Formula = "=COUNTIF('WSA'! D2:D36000,"<N/A")' but no luck. *However, if I put something simple that such as: *.Formula = "=sum(D3:D10)", *it works. *So I suspect the worksheet referencing is in cause here. Thanks for your help |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
help creating new hyperlinks programmatically | Links and Linking in Excel | |||
Querying Properties programmatically | Excel Discussion (Misc queries) | |||
OWC load add-ins programmatically in dotnet? | Excel Discussion (Misc queries) | |||
How to add an image to a worksheet programmatically | Excel Discussion (Misc queries) | |||
Deleting rows programmatically | Excel Worksheet Functions |