Run-time error '1004': Application-defined or object-defined error

RileyC

New Member
Joined
Aug 22, 2018
Messages
42
Code for work, so posting just some of it..
Code that matter for function:
Code:
public function compare(...,table As Range)
dim i as integer
i = 1
table.Cells(i,1).value = "Test"
end function

Throwing error "Run-time error '1004': Application-defined or object-defined error"

Any ideas on why this is happening?
 
Last edited:

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
How are you calling the function & what are you passing to it?
 
Upvote 0
How are you calling the function & what are you passing to it?
Calling the function from the sheet, and passing in a table that is on the sheet. Looks similar to:
Code:
1        2                3                4        5        6        7        8        9           10
Hi       Okay          Yes             No      Maybe So      Just    An      Example ha
Other  Column      Formatted   Similar 
...
 
Last edited:
Upvote 0
Firstly, a UDF is like a formula, in that it cannot modify cells other than the cell that it's in.
Secondly, when you say you are passing it a table, how?
 
Upvote 0
Firstly, a UDF is like a formula, in that it cannot modify cells other than the cell that it's in.
Secondly, when you say you are passing it a table, how?

Alright, is it possible to make something that can modify cells normally? I'm passing in the table like "'Sheet1'!$A$2:$Z$600"
 
Upvote 0
If you want to change cells other than those that contain the function you'll need a macro.
 
Upvote 0
Glad you got it sorted & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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