Getting Application Defined or object defined error for syntax Ws.Cells(1,3).Formula = .......

NimishK

Well-known Member
Joined
Sep 4, 2015
Messages
684
I am getting following error
Getting Application Defined or object defined error in syntax below
Code:
ws.Cells(1, 3).Formula = "=(ws.Cells(1, 1).value) * (ws.Cells(1, 2).value)"

Pl dont show any .formula with range

thanks
NimishK
 
Last edited:

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
That is not a valid excel worksheet formula. Try

Code:
ws.Cells(1,3).Formula = "=$A$1*$B1"
 
Last edited:
Upvote 0
Very Spontaneous Reply Mikerickson sir, any other method using the ws.cells(1,2).value * ws.cells(1, 3).value
because i will be using the same in the loop
 
Upvote 0
Hi

Like Mike said that is not a valid formula.
The worksheet won't understand a formula like

=(ws.Cells(1, 1).value) * (ws.Cells(1, 2).value)


You must build the formula respecting the formula syntax, like

Code:
ws.Cells(1, 3).Formula = "=" & ws.Cells(1, 1).address & "*" & ws.Cells(1, 2).address

so that the resulting value for the formula will be something like

Code:
ws.Cells(1,3).Formula = "=$A$1*$B1"

which is understandable by the worksheet
 
Upvote 0
What loop are you using to enter which (desired) formula?
I suspect that entering a single valid formula with relative referencing might eliminate the loop.
 
Upvote 0
Thanks PGC01 and Mike for your valuable inputs

The following is in the loop
Code:
''''Following Col nos BD=AV3+AY3+SUM(AZ:BC3)+AP3 to get the below formula
ws.Cells(curRow, 56).Formula = "=AV" & curRow & "+AY" & curRow & "+" & "Sum(AZ" & curRow & ":BC" & curRow & "+AP" & curRow
but difficult part is that i am not able to place as per BD=AV3+AY3+SUM(AZ:BC3)+AP3
 
Last edited:
Upvote 0
PGC01 Sir

Actually Absolute refernce in my case will not be appropriate as i fear of miscalculations. I will have to go with Range only
like
Code:
ws.Cells(curRow, 2).Formula = "=A1*B1"


Sirs will appreciate your help for Post 6
 
Last edited:
Upvote 0
Actually Absolute refernce in my case will not be appropriate as i fear of miscalculations. I will have to go with Range only
like
Code:
ws.Cells(curRow, 2).Formula = "=A1*B1"


Sirs ...will appreciate your help for Post 6

...will appreciate your help for Post 6

1 - You missed the closing parenthesis on the SUM()

Code:
ws.Cells(curRow, 56).Formula = "=AV" & curRow & "+AY" & curRow & "+" & "Sum(AZ" & curRow & ":BC" & curRow & "[COLOR=#800000][SIZE=3][B])[/B][/SIZE][/COLOR]+AP" & curRow

2 -

You can define the freezing in the cell address, like

Code:
MsgBox r.Address(RowAbsolute:=False, ColumnAbsolute:=False)

or simply

Code:
MsgBox r.Address(False, False)
 
Upvote 0
Or you could use R1C1 notation and not involve curRow in the formula being entered.

Code:
ws.Cells(curRow, 56).FormulaR1C1 = "=RC48+RC51+SUM(RC52:RC55)+RC42"

You don't specify what the values curRow loops through, but (if the incriment is 1) you could use code like this without having to loop

Code:
ws.Range("BD1:BD10").FormulaR1C1 = "=RC48+RC51+SUM(RC52:RC55)+RC42"
 
Upvote 0
Thank you sirs for your valuable inputs.
I need to still go into depth of Formula R1C1. Have neve gone through it.
Thank you once more
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,196
Members
449,072
Latest member
DW Draft

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top