Hi, I’m using Excel 2021 and am running into a strange and for me an unexpected and strange error.
EXPLANATORY INTRODUCTION
I wrote an App as an xlsm (could have been an xlsm as well) the works perfectly.
The is a worksheet named ‘DATA’ and in this worksheet a LISTOBJECT table named ‘Tabel1’ (not given it a ‘real name’ yet but that’s not the problem.
The table has 25 columns and about 404 rows of data in the DataBodyRange
There is a user form in which there’s a Frame with about 10 fields to be completed and a LISTBOX with the same 25 columns; this works as designed, no issues there.
The form is displayed as modeless (but if modal the same issue occurs)
When the user selects any record in the LISTBOX the 10 fields are populated
There is a button to EDIT the record and there is button to ADD a new record
All this is quite straight forward.
When the user clicks the EDIT button the fields are unlocked and the user edits the entries, when finished the user presses the EDIT button again (Caption has changed to ‘Save Modifications’ and the record is correctly updated.
Works like designed. Perfect
When the user presses ADD the 10 fields are cleared and unlocked and the user can fill in the fields
When finished, the user presses the ADD button (Caption is now ‘Save New Record’ and a new row is added to the LISTBOX at the bottom copying the format of the above row and the record is saved in this new row. Again, no problems.
The macro for this routine
The section to populate the different columns is the same as saving the modified record but using the new table row returned by the function![]()
Please Login or Register to view this content.
WHAT I CHANGED AND WHAT HAPPENS NOW
Because I did not want the file with the Table to be macro-embedded to avoid having to update the table every time something needs to be changed , I removed the DATA sheet from the xlsb file.
This file I saved as an xlam file (AddIn extension) so it only and you access the Userform pressing Crl + Shift + M
The user form opens looks for the file with the data and opens it, and populates the Userform. All works as designed.
When I edit a record and save it, it saves it and you can continue editing until you finish
The problem is only when ADDING a new record.
Of course; the macros have all been set to refer to the now ‘external’ file with the data but if I use the Add_Tablerow_to_Bottom or any other method of adding a row to the table Excel either throws an error or it just closes and nothing is added.
When I try it manually and invoke the macro form the direct window with al, the parameters the same thing happens and debug does tell me to End or Debug but Excel just closes.
Anybody any ideas?
The only thing I need is to be able to add a new table row to an existing LISTOBJECT in another file from the calling file.
I’ve also tried it this way
And I’ve also tried it this way![]()
Please Login or Register to view this content.
Simply adding a row the table before saving also gives an error and the file is closed![]()
Please Login or Register to view this content.
![]()
Bookmarks