• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

VBA to update vendor information|VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / VBA to update vendor information|VBA & Macros|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumVBA & MacrosVBA to update vendor information
sp_PrintTopic sp_TopicIcon
VBA to update vendor information
Avatar
Jose Zavala
Member
Members
Level 0
Forum Posts: 41
Member Since:
October 25, 2017
sp_UserOfflineSmall Offline
1
February 25, 2022 - 1:36 am
sp_Permalink sp_Print

Hi,

 

I found the code below am using  to add new vendors, how can I modify it that can use for updating existing vendors just to update some information to already existing vendor when new information received to update only.

 

here is the code:

 

Private Sub CommandButton4_Click()
Dim lastrow As Long
lastrow = Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row + 1

Sheets("Sheet1").Cells(lastrow, 1).Value = Me.TextBox1.Value
Sheets("Sheet1").Cells(lastrow, 2).Value = Me.TextBox5.Value
Sheets("Sheet1").Cells(lastrow, 3).Value = Me.TextBox2.Value
Sheets("Sheet1").Cells(lastrow, 4).Value = Me.TextBox3.Value
Sheets("Sheet1").Cells(lastrow, 5).Value = Me.TextBox4.Value

MsgBox " Data sucessfully Add"

Me.TextBox1.Value = ""
Me.TextBox2.Value = ""
Me.TextBox3.Value = ""
Me.TextBox4.Value = ""


End Sub

Thank you,
Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1515
Member Since:
October 5, 2010
sp_UserOnlineSmall Online
2
February 25, 2022 - 1:47 pm
sp_Permalink sp_Print

Hi Jose,

Please supply the workbook that you want this to work with.  It's very difficult to provide you an answer without that workbook's data and userform.

regards

Phil

Avatar
Jose Zavala
Member
Members
Level 0
Forum Posts: 41
Member Since:
October 25, 2017
sp_UserOfflineSmall Offline
3
February 26, 2022 - 4:35 am
sp_Permalink sp_Print

Hi Philip,

 

atttached.

Avatar
Jose Zavala
Member
Members
Level 0
Forum Posts: 41
Member Since:
October 25, 2017
sp_UserOfflineSmall Offline
4
March 1, 2022 - 2:25 am
sp_Permalink sp_Print

Hi Phillip,

 

I added sample of the file, any help?

 

Thank you,

Avatar
Jessica Stewart
Northern USA
Member
Members


Trusted Members
Level 0
Forum Posts: 202
Member Since:
February 13, 2021
sp_UserOfflineSmall Offline
5
March 1, 2022 - 7:25 am
sp_Permalink sp_Print sp_EditHistory

Hi Jose,

Here try this. Double click on a row in Disc_Code to bring up your userform and the update button will update your information and unload your form. I had issues at first but I think that is because your cancel button isn't unloading your form, it's hiding it. You want your code to be Unload Me. I made that change as well. Hope this helps! Let me know if you have any questions.

The codes I wrote are housed in the worksheet before double click event and the userform click event for the update button.

Avatar
Jose Zavala
Member
Members
Level 0
Forum Posts: 41
Member Since:
October 25, 2017
sp_UserOfflineSmall Offline
6
March 1, 2022 - 11:06 am
sp_Permalink sp_Print

Thank you very much, worked perfectly.

 

One question if possible how to add "NextRecord" & "PrevRecord" in the form.

 

thanks again.

Avatar
Jessica Stewart
Northern USA
Member
Members


Trusted Members
Level 0
Forum Posts: 202
Member Since:
February 13, 2021
sp_UserOfflineSmall Offline
7
March 1, 2022 - 5:43 pm
sp_Permalink sp_Print sp_EditHistory

I would use offset. Offset 1 row for next record and offset -1 row for previous record. Just copy the code to fill the form and instead of cells.value you want cells.offset().value. Inside the () type either the 1 or the -1 for the rowoffset.

Avatar
Jose Zavala
Member
Members
Level 0
Forum Posts: 41
Member Since:
October 25, 2017
sp_UserOfflineSmall Offline
8
March 2, 2022 - 3:00 pm
sp_Permalink sp_Print

Sorry, but I have no idea what you mean would you mind writing it do I need to create two command button for previous and next?

 

Thank you again

Avatar
Jessica Stewart
Northern USA
Member
Members


Trusted Members
Level 0
Forum Posts: 202
Member Since:
February 13, 2021
sp_UserOfflineSmall Offline
9
March 3, 2022 - 1:55 am
sp_Permalink sp_Print

Something like this.

ActiveCell.Offset(rowoffset:=-1).Select
UserForm1.TextBox1.Value = Sheet2.Cells(ActiveCell.Row, 1).Value
UserForm1.TextBox2.Value = Sheet2.Cells(ActiveCell.Row, 2).Value
UserForm1.TextBox3.Value = Sheet2.Cells(ActiveCell.Row, 3).Value
UserForm1.TextBox4.Value = Sheet2.Cells(ActiveCell.Row, 4).Value
UserForm1.TextBox5.Value = Sheet2.Cells(ActiveCell.Row, 5).Value
UserForm1.TextBox6.Value = Sheet2.Cells(ActiveCell.Row, 6).Value
UserForm1.TextBox7.Value = Sheet2.Cells(ActiveCell.Row, 7).Value
UserForm1.TextBox8.Value = Sheet2.Cells(ActiveCell.Row, 8).Value

For some reason I was thinking about your project this morning and thought of a couple issues with my advice. This is the thing I could think of off hand to correct the issues I thought about. There might be a better way to do it, too; there are usually several ways in Excel.

Yes, you would need a way on the userform to execute the macro. Hope this gets you going.

Avatar
Jose Zavala
Member
Members
Level 0
Forum Posts: 41
Member Since:
October 25, 2017
sp_UserOfflineSmall Offline
10
March 3, 2022 - 5:03 am
sp_Permalink sp_Print

Thank you so much for all your help, much appreciated.

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Philip Treacy, Riny van Eekelen, Sally Riley, Ahmad Alkhuffash, Ramon Lagos, michael serna
Guest(s) 10
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 870
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
A.Maurizio: 202
Jessica Stewart: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
michael serna
mashal sana
Tiffany Kang
Leah Gillmore
Sopi Yuniarti
LAFONSO HERNANDEZ
Hayden Hao
Angela chen
Sean Moore
John Chisholm
Forum Stats:
Groups: 3
Forums: 24
Topics: 6215
Posts: 27245

 

Member Stats:
Guest Posters: 49
Members: 31897
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.