June 26, 2016
Hello everybody
My problem is this:
On a sheet of excel in the column (D3: D100) I insert dates not only imprinted on the year of various genes.
Then in cell (J8) I enter this formula:
=CONTA.PIÙ.SE($D$3:$D$42;">=1930";$D$3:$D$42;"<=1970")
And so far so good.
But now I would also like to insert this formula by writing everything using the vba
I tried to write it like this:
sheets("es2_edifici").Range("K8").Formula= sheets("es2_edifici").Range("K8").Formula= "=CONTA.PIÙ.SE($D$3:$D$42;">=1930";$D$3:$D$42;"<=1970")"
But in doing so he continues to give me error; Why ?
And how can I solve this problem Thank you
Trusted Members
October 18, 2018
You need to preface the countifs function in VBA with
Application.WorksheetFunction
See this link for further understanding.
Power Query
Power Pivot
Xtreme Pivot Tables
Excel for Decision Making
Excel for Finance
Excel Analysis Toolpak
Power BI
Excel
Word
Outlook
Excel Expert
Excel Customer Service
PowerPoint
November 8, 2013
If you are trying to write the cell formula from VBA, you have to duplicate the double quotes within the formula string:
.Range("K8").Formula= "=Countifs($D$3:$D$42;"">=1930"";$D$3:$D$42;""<=1970"")"
The easiest way to get the syntax right is to record a macro while typing that formula in a cell.
Why is the part in red below twice? Should be once, remove the duplicate.
sheets("es2_edifici").Range("K8").Formula= sheets("es2_edifici").Range("K8").Formula= "=CONTA.PIÙ.SE($D$3:$D$42;">=1930";$D$3:$D$42;"<=1970")"
Trusted Members
Moderators
November 1, 2018
1 Guest(s)