ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   insert formula (https://www.excelbanter.com/excel-programming/337397-insert-formula.html)

[email protected]

insert formula
 
Hello,
I thought I posted this, but I did not see it on the website.

I need help with inserting a formula into a selected range. After I
insert this formula I want to copy this formula down to the other rows
of the spreadsheet with the text 'target renewal'. When I try to simply
insert the formula the first time, I get 'Type mismatch error'. I have
not tried to copy yet, cause I can't even insert the formula. I am
lost, can someone help me.

Thanks


For intx = 1 To lngrow
Cells(intx, 1).Select
If InStr(1, ActiveCell.Value, " Target Renewal") 0
Then
Range(Cells(intx, 6), Cells(intx, 20)).Select
Selection.Formula =
"=IF(AND(OR($D$2=30,$D$2=60),D15=""aprent"")," -
",IF(OR(E19=$B$2*(1-($D$2/30)),E19=$B$2*(1-(($D$2-30)/30)),E19=$B$2*(1-(($D$2-60)/30)),E19=$B$2*(1-(($D$2-90)/30)),E19=$B$2),$B$2,IF((F15+$D$2)<30,$B$2*(1-($D$2/30)),IF(OR(D15=""aprent"",F150),"
- ",IF((F15+E15+$D$2)<60,$B$2*(1-(($D$2-30)/30)),IF(D19=""," -
",IF((D15+E15+F15+$D$2)<90,$B$2*(1-(($D$2-60)/30))," - ")))))))"
Selection.Value = Selection.Value
End If
Next


Charlie

insert formula
 
It appears at a glance that you still have work to do on your "doubled-up"
quote marks within the string value.

Selection.Formula = "=IF(AND(OR($D$2=30,$D$2=60),D15=""aprent"")," -

(it looks good up to ""aprent"", but need to double-up quote marks beyond
that, i.e. "" - "")


" wrote:

Hello,
I thought I posted this, but I did not see it on the website.

I need help with inserting a formula into a selected range. After I
insert this formula I want to copy this formula down to the other rows
of the spreadsheet with the text 'target renewal'. When I try to simply
insert the formula the first time, I get 'Type mismatch error'. I have
not tried to copy yet, cause I can't even insert the formula. I am
lost, can someone help me.

Thanks


For intx = 1 To lngrow
Cells(intx, 1).Select
If InStr(1, ActiveCell.Value, " Target Renewal") 0
Then
Range(Cells(intx, 6), Cells(intx, 20)).Select
Selection.Formula =
"=IF(AND(OR($D$2=30,$D$2=60),D15=""aprent"")," -
",IF(OR(E19=$B$2*(1-($D$2/30)),E19=$B$2*(1-(($D$2-30)/30)),E19=$B$2*(1-(($D$2-60)/30)),E19=$B$2*(1-(($D$2-90)/30)),E19=$B$2),$B$2,IF((F15+$D$2)<30,$B$2*(1-($D$2/30)),IF(OR(D15=""aprent"",F150),"
- ",IF((F15+E15+$D$2)<60,$B$2*(1-(($D$2-30)/30)),IF(D19=""," -
",IF((D15+E15+F15+$D$2)<90,$B$2*(1-(($D$2-60)/30))," - ")))))))"
Selection.Value = Selection.Value
End If
Next




All times are GMT +1. The time now is 04:19 AM.

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