| | |
difficulty creating a formula with a macro
![]() |
•
•
Join Date: Nov 2006
Posts: 1
Reputation:
Solved Threads: 0
Hello, all
I am having some difficulty in a part of a macro where I want to insert this formula in an Excel spreadsheet.
=IF(TRIM(D12)="REG:",1,0)+IF(E12,1,0)
When executed, one of the problems I am having is that apostrophes are inserted around "E12", so the second IF looks like:
IF('E12',1,0)
and excel marks it with an error...
I bypassed the same error on the TRIM function by writing it like this:
TRIM("D12").
If I try the same method for the IF(E12,1,0) part, I get a syntax error.
This is the actual statement from the VB macro:
ActiveCell.FormulaR1C1 = "=IF(TRIM(""D" & detailrow & """)=""GEO:"",1,0)+IF(E" & detailrow & ",1,0)"
and this is the result:
=IF(TRIM("D12")="GEO:",1,0)+IF('E12',1,0)
Thanks in advance for any suggestions
Carlos
I am having some difficulty in a part of a macro where I want to insert this formula in an Excel spreadsheet.
=IF(TRIM(D12)="REG:",1,0)+IF(E12,1,0)
When executed, one of the problems I am having is that apostrophes are inserted around "E12", so the second IF looks like:
IF('E12',1,0)
and excel marks it with an error...
I bypassed the same error on the TRIM function by writing it like this:
TRIM("D12").
If I try the same method for the IF(E12,1,0) part, I get a syntax error.
This is the actual statement from the VB macro:
ActiveCell.FormulaR1C1 = "=IF(TRIM(""D" & detailrow & """)=""GEO:"",1,0)+IF(E" & detailrow & ",1,0)"
and this is the result:
=IF(TRIM("D12")="GEO:",1,0)+IF('E12',1,0)
Thanks in advance for any suggestions
Carlos
![]() |
Similar Threads
- query for creating report group by weeks (with start date and end date of the week) (MS SQL)
- Macro in MSExcel (Visual Basic 4 / 5 / 6)
- remove install software warning - not digitally signed (Windows NT / 2000 / XP)
- automating installation problem (IT Professionals' Lounge)
- storing details as html doc using php (PHP)
- JAVA HELP NEEDED, for plotting, URGENT (Java)
- member group query (MySQL)
- Creating data access layer in java (Java)
- Trying to run Showcase thru a Macro built in VB (Visual Basic 4 / 5 / 6)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Reading Files In Vb
- Next Thread: Alter Recordset by Text Box text.
| Thread Tools | Search this Thread |
* 6 2007 access activex add age basic beginner birth bmp calculator cd cells.find click client code college connection connectionproblemusingvb6usingoledb creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit excel excelmacro file filename form header iamthwee image inboxinvb internetfiledownload listbox listview liveperson login looping microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading remotesqlserverdatabase report save search sendbyte sites sql sql2008 sqlserver subroutine tags time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web windows





