| | |
difficulty creating a formula with a macro
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
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 |
Tag cloud for Visual Basic 4 / 5 / 6
* 6 429 2007 access activex add age append application basic beginner birth bmp calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver subroutine table tags textbox time timer urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





