+ Reply to Thread
Results 1 to 5 of 5

Adding a new Item overwrite the existing one previously edited

  1. #1
    Registered User
    Join Date
    11-11-2023
    Location
    Europe
    MS-Off Ver
    365
    Posts
    6

    Adding a new Item overwrite the existing one previously edited

    Hello everyone,
    I'm seeking assistance with a challenge I'm facing. I've been working on a UserForm to facilitate the insertion of items, and I've nearly achieved the desired functionality. However, I've encountered an unexpected behavior that I need help addressing.
    Upon launching the form, filling in the required information, and clicking the Save button, the new item is correctly added in a new row on the worksheet, functioning as intended.
    The issue arises when editing an existing item. While the modifications are saved to the same item, if I subsequently attempt to add a new item, the new information overwrites the previously edited item.
    This behavior is not present when deleting an existing item.
    I've tried examining the code to identify the cause of this behavior, but being super new to VBA, I'm struggling to pinpoint the issue. Could you please review the code and assist me in resolving this problem?
    Attached the file I'm working on.
    Thank you in advance for your help!
    Attached Files Attached Files
    Last edited by colosalit; 11-22-2023 at 06:52 AM.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,981

    Re: Adding a new Item overwrite the existing one previously edited

    Administrative Note:

    Welcome to the forum.

    Although we value your privacy as much you do, it could be important that members have a rough idea of your location as the solutions they offer may be affected by your locale. For instance, you might in the future post questions which are related to your regional settings.

    With this in mind, please update your profile to something more precise (something such as UK, Europe, USA, UAE, etc. will suffice).

    Thank you for helping us to help you.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,224

    Re: Adding a new Item overwrite the existing one previously edited

    You are missing the cleaning of the txtRowNumber control in the Module1.Initialize procedure.
    Please Login or Register  to view this content.
    By the way, I have a request for you to check a certain thing. As I understand, with your system settings, in the InitializeListBox procedure, this line works correctly
    Please Login or Register  to view this content.
    With my settings, it generates an error. Please check that if you change the separators from comma to semicolon you get the error "Could not set the ColumnWidths property".
    Please Login or Register  to view this content.
    The feedback is important to me for the future.

    Artik

  4. #4
    Registered User
    Join Date
    11-11-2023
    Location
    Europe
    MS-Off Ver
    365
    Posts
    6

    Re: Adding a new Item overwrite the existing one previously edited

    Thank you for your prompt response Artik,
    I was following a YouTube video when I constructed that Sub, and in the video, that particular line of code was not included. Now, everything is functioning as it should.
    I also tested changing the separators from a comma to a semicolon, and I didn't encounter any errors when compiling the code or running the form.
    Thanks again!

  5. #5
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,224

    Re: Adding a new Item overwrite the existing one previously edited

    Thank you for your feedback.

    Artik

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Copy existing (hidden) worksheet and replace/overwrite existing worksheet in same workbook
    By Funkymonkey0073 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-11-2020, 08:44 AM
  2. [SOLVED] Adding TextBox Value Next to Existing Item in ListBox
    By phiko73 in forum Word Programming / VBA / Macros
    Replies: 6
    Last Post: 03-03-2019, 05:58 AM
  3. Hide previously used item from list
    By 888ball in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-12-2019, 09:00 PM
  4. Save As PDF And (please do not) Overwrite Existing
    By cangokturk in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-06-2016, 02:30 PM
  5. adding new item in dropdown & using existing item as new record
    By lui de sagun in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-05-2015, 02:33 AM
  6. PLease Help: Dropdown list that removes previously selected item
    By Gus88 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-01-2014, 01:28 PM
  7. Overwrite existing data
    By kishoremcp in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-21-2012, 09:10 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1