ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Application-Defined or Object-Defined Error on simple code (https://www.excelbanter.com/excel-programming/335205-application-defined-object-defined-error-simple-code.html)

Fid[_2_]

Application-Defined or Object-Defined Error on simple code
 
I seem to continually struggle with this error anytime I write vba code
for excel.

I have the following code:

Private Sub cmdUpdate_Click()

Workbooks("Inventory").Worksheets("RawData").Colum ns("G").Replace
What:="{01", Replacement:="Newton", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub

This code runs when a user clicks a command button but always gives me
the application-defined or object-defined error. Others who have
tried to help me say they cannot replicate the error. Is anyone else
struggling with this?

Thanks,

Brent


Chip Pearson

Application-Defined or Object-Defined Error on simple code
 
If the button is on a worksheet, and you are in Excel97, change
the TakeFocusOnClick property to False. This is a bug that was
fixed in 2000.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Fid" wrote in message
ps.com...
I seem to continually struggle with this error anytime I write
vba code
for excel.

I have the following code:

Private Sub cmdUpdate_Click()

Workbooks("Inventory").Worksheets("RawData").Colum ns("G").Replace
What:="{01", Replacement:="Newton", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:=False, _
ReplaceFormat:=False
End Sub

This code runs when a user clicks a command button but always
gives me
the application-defined or object-defined error. Others who
have
tried to help me say they cannot replicate the error. Is
anyone else
struggling with this?

Thanks,

Brent





All times are GMT +1. The time now is 09:44 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com