+ Reply to Thread
Results 1 to 32 of 32

Code to Update Vehicle Details

  1. #1
    Forum Contributor
    Join Date
    02-26-2023
    Location
    Lousianna
    MS-Off Ver
    Microsoft 365
    Posts
    932

    Code to Update Vehicle Details

    Hello,

    Can there be VBA code to update Vehicle details from the Vehicle Expense Tracker sheet to the Vehicle List sheet?

    I want the ability to edit details please.

    Thank you kindly for your help
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,203

    Re: Code to Update Vehicle Details

    Please Login or Register  to view this content.
    This will not work as the highlighted are merged cells: and I am sure you have been advised previously about NOT using merged cells.


    The attached uses a TEXTBOX for the entry of the notes.

    Please Login or Register  to view this content.
    G1 in "Vehicle List" is set to blank to cater for the TEXTBOX addition:
    Attached Files Attached Files
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  3. #3
    Forum Contributor
    Join Date
    02-26-2023
    Location
    Lousianna
    MS-Off Ver
    Microsoft 365
    Posts
    932

    Re: Code to Update Vehicle Details

    Thanks I don't want to add more vehicles but rather update details of a current vehicle. There are currently a maximum of 10 vehicles for this workbook which I want to maintain.

    I appreciate the help and yes it is not good practice to have merged data cells.

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,203

    Re: Code to Update Vehicle Details

    I did mis-read your post as you said update so are you going have an UPDATE button in addition to ADD ?
    Last edited by JohnTopley; 03-28-2024 at 06:04 AM.

  5. #5
    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,844

    Re: Code to Update Vehicle Details

    To be fair, Billy mentioned BOTH in the opening post, and 'update' is also in the thread title.
    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.

  6. #6
    Forum Contributor
    Join Date
    02-26-2023
    Location
    Lousianna
    MS-Off Ver
    Microsoft 365
    Posts
    932

    Re: Code to Update Vehicle Details

    It will be starting with no cars entered at first. These are just samples. Then the user can add up to 10 cars. I will have to adjust the row limits in the code.

    What I had asked for (probably my poor explanation) was to edit details of any of the cars that exist.

    I did notice that if there aren't any pictures for a car when navigating it goes to debug though.

    Thank you

    Yes there should be an update button sorry

  7. #7
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,203

    Re: Code to Update Vehicle Details

    @AliGW: yes, I apologised as I did mis-read the initial post.

  8. #8
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,203

    Re: Code to Update Vehicle Details

    So, are you going to use an UPDATE button as well as ADD?

    And do you want a check on the car limit (of 10) ?

  9. #9
    Forum Contributor
    Join Date
    02-26-2023
    Location
    Lousianna
    MS-Off Ver
    Microsoft 365
    Posts
    932

    Re: Code to Update Vehicle Details

    Yes please sir

  10. #10
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,203

    Re: Code to Update Vehicle Details

    ..... how about DELETE of cars? And are there fields that can not be changed as (to me) the only variable is NOTES unless a car undergoes a change of specification.

  11. #11
    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,844

    Re: Code to Update Vehicle Details

    I wonder if UPDATE really means CHANGE TO A DIFFERENT CAR?

  12. #12
    Forum Contributor
    Join Date
    02-26-2023
    Location
    Lousianna
    MS-Off Ver
    Microsoft 365
    Posts
    932

    Re: Code to Update Vehicle Details

    Yes it does seem that the notes field would be a field that could change for perhaps a particular future issue detail. But maybe the user entered an incorrect plate number for instance?

    Yes a delete of a car would be beneficial. The user may trade in a car so would have new car to enter.

  13. #13
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    1,980

    Re: Code to Update Vehicle Details

    See if this helps.

    In the Vehicle_Macs module
    Declare public variable and function
    Please Login or Register  to view this content.
    assign the variable during vehicle load
    Please Login or Register  to view this content.

    Change the Save routine
    Please Login or Register  to view this content.
    In Sheet1 change event
    Please Login or Register  to view this content.
    Attached Files Attached Files

  14. #14
    Forum Contributor
    Join Date
    02-26-2023
    Location
    Lousianna
    MS-Off Ver
    Microsoft 365
    Posts
    932

    Re: Code to Update Vehicle Details

    Thank you @ByteMarks.

    I see that when changing a detail the SAVE button appears which is great!

    I tried to enter a new vehicle when there are already 10 vehicles. Could there be an error check or perhaps the ADD button not showing when 10 vehicles are in the vehicle list?

  15. #15
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,203

    Re: Code to Update Vehicle Details

    With ByteMarks code I get an error when adding a new vehicle

  16. #16
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    1,980

    Re: Code to Update Vehicle Details

    Maybe this in the workbook open and then make the same assessment wherever you set it to true.

    Please Login or Register  to view this content.

  17. #17
    Forum Contributor
    Join Date
    02-26-2023
    Location
    Lousianna
    MS-Off Ver
    Microsoft 365
    Posts
    932

    Re: Code to Update Vehicle Details

    Yes I also get error adding new vehicle.

  18. #18
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    1,980

    Re: Code to Update Vehicle Details

    Post #3
    I don't want to add more vehicles
    Didn't look at that part yet. If it's limited to 10 you can't add more without first deleting some?

  19. #19
    Forum Contributor
    Join Date
    02-26-2023
    Location
    Lousianna
    MS-Off Ver
    Microsoft 365
    Posts
    932

    Re: Code to Update Vehicle Details

    Yes I put limit of rows to A13 so no additional rows could be added but I still get error.

    So it would be a benefit to either warn the user that the maximum of 10 vehicles have been added or after 10 are in the list take away the add vehicle button (not show).

  20. #20
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,203

    Re: Code to Update Vehicle Details

    I think this should be

    Please Login or Register  to view this content.

  21. #21
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    1,980

    Re: Code to Update Vehicle Details

    My logic was that the "Add" button should only be visible if <10 cars so < row 13.
    If < 14 then 10 cars are already populated in rows 4 to 13 so the button should be hidden.

    What error you getting btw? I'm not getting any.

  22. #22
    Forum Contributor
    Join Date
    02-26-2023
    Location
    Lousianna
    MS-Off Ver
    Microsoft 365
    Posts
    932

    Re: Code to Update Vehicle Details

    Under Save:

    VehRow = .Range("B4")

  23. #23
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    1,980

    Re: Code to Update Vehicle Details

    oh yes. Change it to this.


    Please Login or Register  to view this content.

  24. #24
    Forum Contributor
    Join Date
    02-26-2023
    Location
    Lousianna
    MS-Off Ver
    Microsoft 365
    Posts
    932

    Re: Code to Update Vehicle Details

    Could the Add button be hidden when max vehicles have been entered?

    Last request thanks.

  25. #25
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    1,980

    Re: Code to Update Vehicle Details

    I should be from post #16
    But wherever you previously set the button visibility to msoTrue, you need to assess the row count.

    Please Login or Register  to view this content.

  26. #26
    Forum Contributor
    Join Date
    02-26-2023
    Location
    Lousianna
    MS-Off Ver
    Microsoft 365
    Posts
    932

    Re: Code to Update Vehicle Details

    It's still there even though 10 vehicles.

  27. #27
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    1,980

    Re: Code to Update Vehicle Details

    Does it work in this file?
    Attached Files Attached Files

  28. #28
    Forum Contributor
    Join Date
    02-26-2023
    Location
    Lousianna
    MS-Off Ver
    Microsoft 365
    Posts
    932

    Re: Code to Update Vehicle Details

    Yes very good! Thank you so much for your fantastic help!

    If I select another tab at top and come back to vehicles the Add button appears until I select a car then it disappears.
    Last edited by billy60; 03-28-2024 at 08:01 AM.

  29. #29
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    1,980

    Re: Code to Update Vehicle Details

    You're welcome. Glad I could help.

  30. #30
    Forum Contributor
    Join Date
    02-26-2023
    Location
    Lousianna
    MS-Off Ver
    Microsoft 365
    Posts
    932

    Re: Code to Update Vehicle Details

    I added Vehicle_Load

    Please Login or Register  to view this content.

  31. #31
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    1,980

    Re: Code to Update Vehicle Details

    Good call.

    btw in the file I attached I did comment out Vehicle_AddPic and Vehicle_ShowPic, so you should uncomment those.

  32. #32
    Forum Contributor
    Join Date
    02-26-2023
    Location
    Lousianna
    MS-Off Ver
    Microsoft 365
    Posts
    932

    Re: Code to Update Vehicle Details

    Yes I did that thanks. I realized that my file location for pics won't apply for you so it goes to error when there aren't any pics to find.


+ 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. Index vehicle, driver and vehicle wise revenue report.
    By dackson in forum Excel Formulas & Functions
    Replies: 41
    Last Post: 06-02-2017, 01:40 AM
  2. [SOLVED] Update details using VBA UserForm
    By Anarchus in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-18-2016, 01:56 AM
  3. [SOLVED] Sample -Required to update Summary Details in Each Tab of Split data at end using VBA Code
    By Ram_G in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-24-2016, 05:40 AM
  4. Vehicle # with Customer id Codition Modify Code
    By hsc14 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-04-2015, 01:57 AM
  5. Replies: 2
    Last Post: 01-30-2013, 12:06 PM
  6. update details on one tab from another tab in same book
    By maax555 in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 02-29-2012, 12:01 PM
  7. update details using vba
    By Noemi in forum Excel General
    Replies: 5
    Last Post: 10-25-2005, 10:05 AM

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