• 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

Data update coding|VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / Data update coding|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 & MacrosData update coding
sp_PrintTopic sp_TopicIcon
Data update coding
Avatar
Matthew Pitt
Member
Members
Level 0
Forum Posts: 7
Member Since:
April 2, 2022
sp_UserOfflineSmall Offline
1
April 26, 2022 - 12:20 pm
sp_Permalink sp_Print

I have attached a demo version of my work sheet along with the script that I am running.

 

What I am trying to figure out is the script to allow the second userform (Document Details) to be changed which would then update the spreadsheet.

 

On the spreadsheet currently, there is a search button in the left corner. Once selected, a search userform will show up where you can either search based on document number of document name. Once the parameters of the search are entered, select the search button on the userform which will populate the table on the userform. This will show all documents that have matched the search parameters. 

Once you have found the document you are after, select it from the list and then click "Show Selected". This will bring up a second userform that provides extensive details about the selected document. This the form that I would like to script to change the data in the workbook. For example, if the version number was to change, I could change it on this userform and it would update the worksheet once the "Update Information" button was selected.

 

Any help would be greatly appreciated.

 

Cheers, 

Avatar
Catalin Bombea
Iasi, Romania
Admin
Level 10
Forum Posts: 1810
Member Since:
November 8, 2013
sp_UserOfflineSmall Offline
2
May 1, 2022 - 10:26 pm
sp_Permalink sp_Print

Hi Matthew,

When you press Show Selected, you do know the row number from the worksheet, you just have to pass it to the other form.

You can do that using a tag, of the form, or of another object from that form.

Here is the updated code:

Private Sub showselected_Click()
If Results.ListIndex = -1 Then Exit Sub ' no row selected

Dim RW As Long, Wks As Worksheet
Set Wks = ThisWorkbook.Worksheets("Forms")
RW = Results.List(Results.ListIndex, 3)
DocumentDetails.TextBox2.Value = Wks.Cells(RW, "A")
DocumentDetails.TextBox6.Value = Wks.Cells(RW, "C")
DocumentDetails.TextBox3.Value = Wks.Cells(RW, "B")
DocumentDetails.TextBox7.Value = Wks.Cells(RW, "D")
DocumentDetails.TextBox8.Value = Wks.Cells(RW, "E")
DocumentDetails.TextBox9.Value = Wks.Cells(RW, "F")
DocumentDetails.TextBox10.Value = Wks.Cells(RW, "G")
DocumentDetails.TextBox11.Value = Wks.Cells(RW, "H")
DocumentDetails.TextBox12.Value = Wks.Cells(RW, "I")
DocumentDetails.TextBox13.Value = Wks.Cells(RW, "J")
DocumentDetails.TextBox14.Value = Wks.Cells(RW, "K")
DocumentDetails.TextBox15.Value = Wks.Cells(RW, "L")

'continue with the rest of the textboxes needed
DocumentDetails.Tag = RW 'store the row number of the worksheet in the form tag
DocumentDetails.Show

End Sub

 

Then, from the Update Information button:

Private Sub CommandButton1_Click()

Dim RW As Long

RW = CLng(Me.Tag) 'read the row that was stored in the current form tag

Worksheets("forms").Cells(RW, 2).Value = TextBox3.Text
Worksheets("forms").Cells(RW, 3).Value = TextBox6.Text
Worksheets("forms").Cells(RW, 4).Value = TextBox7.Text
Worksheets("forms").Cells(RW, 5).Value = TextBox8.Text
Worksheets("forms").Cells(RW, 6).Value = TextBox9.Text
Worksheets("forms").Cells(RW, 7).Value = TextBox10.Text
Worksheets("forms").Cells(RW, 8).Value = TextBox11.Text
Worksheets("forms").Cells(RW, 9).Value = TextBox12.Text
Worksheets("forms").Cells(RW, 10).Value = TextBox13.Text
Worksheets("forms").Cells(RW, 11).Value = TextBox14.Text
Worksheets("forms").Cells(RW, 12).Value = TextBox15.Text

End Sub

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: RAMEZ ATTAR, SALLY
Guest(s) 9
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 871
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
Jessica Stewart: 205
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
Bruce Tang Nian
Scot C
Othman AL MUTAIRI
Misael Gutierrez Sr.
Attif Ihsan
Kieran Fee
Murat Hasanoglu
Brett Dryland
Saeed Aldousari
Bhuwan Devkota
Forum Stats:
Groups: 3
Forums: 24
Topics: 6222
Posts: 27293

 

Member Stats:
Guest Posters: 49
Members: 31918
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.