[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

error in vba code

Posted on 2011-05-04
6
Medium Priority
?
479 Views
Last Modified: 2012-05-11
Hello,

Could someone please tell me what is the problem with my vba code? When I try to debug it I keep getting that 'error 1004 application-defined or object-defined error'. I have tried different things with the syntax but I can't seem to find the issue. Thanks.



Sub Multiplier()

' Updates Multiplier column with '1' or '-1'
'
  Dim lastRow As Long
    lastRow = Range("A" & Rows.Count).End(xlUp).Row
    Range("E2").Formula = "=IF(OR(A2=41826,A2=50529,A2=50530,A2=51807,A2=51828,A2=51850,A2=51851,A2=51852,A2=51853,A2=51854,A2=51855,A2=51856,A2=51857,A2=51858,A2=51859,A2=51860,A2=51861,A2=51862,A2=51863,A2=51864,A2=51865,A2=51866,A2=51899,A2=E5184_I,A2=E5732_I) ""-1"", ""1"")"
    Range("E2").AutoFill Destination:=Range("E2:E" & lastRow), Type:=xlFillDefault

End Sub
0
Comment
Question by:erp1022
  • 4
  • 2
6 Comments
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 35693654
I have highlighted the error producing parts in bold

    Range("E2").Formula = "=IF(OR(A2=41826,A2=50529,A2=50530,A2=51807,A2=51828,A2=51850,A2=51851,A2=51852,A2=51853,A2=51854,A2=51855,A2=51856,A2=51857,A2=51858,A2=51859,A2=51860,A2=51861,A2=51862,A2=51863,A2=51864,A2=51865,A2=51866,A2=51899,A2=E5184_I,A2=E5732_I),""-1"", ""1"")"
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 35693667
there are two "_I" s and one comma after the second _I
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 35693679
Second try with underlines
    Range("E2").Formula = "=IF(OR(A2=41826,A2=50529,A2=50530,A2=51807,A2=51828,A2=51850,A2=51851,A2=51852,A2=51853,A2=51854,A2=51855,A2=51856,A2=51857,A2=51858,A2=51859,A2=51860,A2=51861,A2=51862,A2=51863,A2=51864,A2=51865,A2=51866,A2=51899,A2=E5184_I,A2=E5732_I),""-1"", ""1"")"
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 43

Assisted Solution

by:Saqib Husain, Syed
Saqib Husain, Syed earned 400 total points
ID: 35693752
Still not much improvement.

Third try using picture
Formula-error.PNG
0
 
LVL 61

Expert Comment

by:HainKurt
ID: 35694036
try

=IF(OR(A2=41826,A2=50529,A2=50530,A2=51807,A2=51828,A2=51850,A2=51851,A2=51852,A2=51853,A2=51854,A2=51855,A2=51856,A2=51857,A2=51858,A2=51859,A2=51860,A2=51861,A2=51862,A2=51863,A2=51864,A2=51865,A2=51866,A2=51899,A2="E5184_I",A2="E5732_I"),"-1","1")
0
 
LVL 61

Accepted Solution

by:
HainKurt earned 1600 total points
ID: 35694044
I mean this code

  Range("E2").Formula = "=IF(OR(A2=41826,A2=50529,A2=50530,A2=51807,A2=51828,A2=51850,A2=51851,A2=51852,A2=51853,A2=51854,A2=51855,A2=51856,A2=51857,A2=51858,A2=51859,A2=51860,A2=51861,A2=51862,A2=51863,A2=51864,A2=51865,A2=51866,A2=51899,A2=""E5184_I"",A2=""E5732_I""), ""-1"", ""1"")"
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question