Hi,
I have the code below in a userform with I click update give me Error 1004 "Application-defined or Object-defined error"
Here is the code:
Thank you,Please Login or Register to view this content.
Hi,
I have the code below in a userform with I click update give me Error 1004 "Application-defined or Object-defined error"
Here is the code:
Thank you,Please Login or Register to view this content.
Where is rowselect defined and/or initialised?
Trevor Shuttleworth - Retired Excel/VBA Consultant
I dream of a better world where chickens can cross the road without having their motives questioned
'Being unapologetic means never having to say you're sorry' John Cooper Clarke
This line start at cell B2 (not sure if this what you mean:
Please Login or Register to view this content.
PHP Code:
SAGEID VENDOR INVOICE_NUMBER PO_NUMBER APPROVER GL_CODE
100215 ABC COMM. 17786-28380,28620, 30862 HD 602110-28-500-100 Fixed Data - Customer - Data Services: C - TCOM - ONT
100109 AFX COMMUNICATIONS 80017 MJT 603202-28-500-100 LD - TF - Other : C - TCOM - ON
100433 AIDEN HODSON TIMESHEET-07242022 JUL 11-24-2022 GLEN GREGORY 609113-28-500-100 Prof Services - Other Customer billable : C - TCOM- ON
100176 AIRSPRING 162072451 JUNE 2022 HD 603220-28-500-100 LD Toll Dal: C - TCOM - ON
100053 ALLSTREAM BUSINESS INC. C/O T4622 254259-NOV 2021 254259-NOV 2021 254259-JS 603220-28-500-100 LD - Toll DAL : C - TCOM - ON
100053 ALLSTREAM BUSINESS INC. C/O T4622 254259-NOV 2021 254259-NOV 2021 254259-JS 323112-08-000-500 HST ITC: G - G - BC
100053 ALLSTREAM BUSINESS INC. C/O T4622 164982-NOV 2021 164982-EK 608110-28-500-100 Fixed Voice - Network - Access & IX : C - TCOM - ON
100053 ALLSTREAM BUSINESS INC. C/O T4622 164982-NOV 2021 NOV-2021 164982-EK 608110-28-500-100 Fixed Voice - Network - Access & IX : C - TCOM - ON
100053 ALLSTREAM BUSINESS INC. C/O T4622 164982-NOV 2021 NOV-2021 164982-EK 608110-28-500-100 Fixed Voice - Network - Access & IX : C - TCOM - ON
100053 ALLSTREAM BUSINESS INC. C/O T4622 164982-NOV 2021 NOV-2021 164982-EK 323112-08-000-500 HST ITC: G - G - BC
100053 ALLSTREAM BUSINESS INC. C/O T4622 17788676 1139885-EK 605150-28-500-100 Local - Resold - Commercial : C - TCOM - ON
100053 ALLSTREAM BUSINESS INC. C/O T4622 17788676 1139885-NOV 2021 1139885-EK 605150-28-500-100 Local - Resold - Commercial : C - TCOM - ON
100053 ALLSTREAM BUSINESS INC. C/O T4622 17788676 1139885-NOV 2021 1139885-EK 605150-28-500-100 Local - Resold - Commercial : C - TCOM - ON
100053 ALLSTREAM BUSINESS INC. C/O T4622 17788676 1139885-NOV 2021 1139885-EK 605150-28-500-100 Local - Resold - Commercial : C - TCOM - ON
Sure. But where do you define rowselect? And where do you give it a value? If it is undefined and you don't set a value, it will be zero or blank or null. Whatever, when you refer to Cells(rowselect, 2) = Me.txtvendor.Value, rowselect won't have a positive numeric value.
Sorry not that good in vba not sure what you mean, would it possible explain to me more, please.
Thank you,
OK. Clearly not explaining this very well. I was hoping to lead you to the answer and there would be a lightbulb moment ... but that isn't happening.
I honestly don't know if there is anything else wrong with your code because I have no way of testing it. No workbook, no forms, no data, etc.
So, if you do not define a variable that you subsequently use, it will have a null value and a zero length. If you define a variable as Integer but don't assign a value, it will have a default value of zero ( 0 ) and a length of 2. f you define a variable as Long but don't assign a value, it will have a default value of zero ( 0 ) and a length of 4. The length is interesting but not that important. Generally, if you define a variable to refer to a row number, I would recommend you use type Long.
When you refer to the variable rowselect in your code, as in:rowselect has not been defined and therefore has a null value. So, effectively, your code saysPlease Login or Register to view this content.
which is not valid.Please Login or Register to view this content.
The variable rowselect must have a positive numeric value to be valid when referring to a row number. A null row does not exist. Row zero does not exist. Hence the code breaks.
You need to a) Dim the variable: Dim rowselect As Long, and b) assign it a suitable value before you use it to refer to a row number.
If you want to start writing your data out from, say, row 2, you would use:
As you are using Find to locate a Target, maybe you should be using Target.Row rather than rowselect?Please Login or Register to view this content.
And also, because you are referring to cells within a With ... End With block, they should have a full stop/period/dot in front of them:Some sample code:Please Login or Register to view this content.
Please Login or Register to view this content.
Last edited by TMS; 11-09-2022 at 01:09 PM.
Hello Joros. In addition to what was commented by TMS, I would try to add:
rowselect = Target.Row
after:
Set Target = .Range("A:A").Find(.....)
Thank you both, TMS and Beyond for all your suggestion. working now.
You're welcome. Thanks for the rep.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks