Comments are available to members only. Sign up or Log in to view these comments.
Main Topics
Browse All TopicsWould anyone have even the slightest idea what might be going wrong with the following code?
Sometimes it works fine, but most of the time I get a 'runtime 1004: application-defined or object-defined error'
NOTES:
-When stepping through application, runtime 1004 error is raised on the 'End Function' of the parseFormula function
Offending Code
------------------
Chunk of offending code from main function
Sheet1.cells(x, y).Value = Sheet1.cells(x, y).Value & parseFormula(ri(i).getPreF
Same as above but I've substituted function calls with the data that's actually being passed
Sheet1.cells(x, y).Value = Sheet1.cells(x, y).Value & parseFormula("1+", 2) ' first var is string, second is integer
Parse Function Formula
--------------------------
' Convert $D to D & row Number
' IE: $D+E$ would return D4+E4 for fourth row, D5+E5 for fifth row, etc...
Public Function parseFormula(ByVal formula As String, ByVal row As Integer) As String
Dim a As Integer
Dim char As String
Dim formattedFormula As String
For a = 1 To Len(formula)
char = Mid(formula, a, 1)
If char = "$" Then
If Asc(LCase(Mid(formula, a + 1, 1))) >= 97 And Asc(LCase(Mid(formula, a + 1, 1))) <= 122 Then
formattedFormula = formattedFormula & Mid(formula, a + 1, 1) & row
a = a + 1
End If
Else
formattedFormula = formattedFormula & Mid(formula, a, 1)
End If
Next a
MsgBox "." & formattedFormula & "."
parseFormula = CStr(formattedFormula)
End Function
in debug, parseFormula does indeed return +1, press F8 again and move to End Function line, press F8 again, runtime 1004
The complete application is avaialble if you would like to test it for yourself.
Thanks in advance
Update: I've been working this problem off and on for a few days now and have finally managed to narrow it down a bit.
Seems it doesn't like the
sheet1.cells(x,y).value = sheet1.cells(x,y).value
since msgbox "." & parseFormula(ri(i).getPreF
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: dragontoothPosted on 2003-10-22 at 13:46:21ID: 9602084
Comments are available to members only. Sign up or Log in to view these comments.