Results 1 to 12 of 12

VBA code to search another workbook

Threaded View

  1. #1
    Registered User
    Join Date
    12-14-2020
    Location
    Bahrain
    MS-Off Ver
    2010
    Posts
    14

    VBA code to search another workbook

    Hello,

    I'm working in a vehicle service centre and I am attempting to create a spreadsheet to track the work through the workshop.
    I have created a sheet with a working search function but would like to seperate the two so that the service advisors can only search and not change the data in the sheet.
    Basically, I want the service advisors to be able to open an excel file with only 1 tab - the search tab and the workshop controller to open the other excel file to input the data.

    Currently tab 1 is the search and tabs 2,4-15 are where the data will be held.
    When I type a 'WIP number' into the first textbox on my userform and click search, the other 8 text boxes are populated with the data corresponding to that WIP number.

    the code is as follows (if someone could also tell me how to search 'allsheets' instead of each sheet individually that would be appreciated)

    Private Sub SEARCH_Click()
    Dim WIP_Number As String
    WIP_Number = Trim(WIPTEXT.Text)
    lastrow = Worksheets("JAN").Cells(Rows.Count, 1).End(xlUp).Row
    For i = 2 To lastrow

    If Worksheets("JAN").Cells(i, 2).Value = WIP_Number Then
    WIPTEXT.Text = Worksheets("JAN").Cells(i, 2).Value
    CARTEXT.Text = Worksheets("JAN").Cells(i, 3).Value
    ADVISORTEXT.Text = Worksheets("JAN").Cells(i, 11).Value
    REQUIREDTEXT.Text = Worksheets("JAN").Cells(i, 6).Text
    COMPLETETEXT.Text = Worksheets("JAN").Cells(i, 10).Text
    STATUSTEXT.Text = Worksheets("JAN").Cells(i, 14).Value
    AUTHORITYTEXT.Text = Worksheets("JAN").Cells(i, 12).Text
    QCTEXT.Text = Worksheets("JAN").Cells(i, 13).Text
    TEAMTEXT.Text = Worksheets("JAN").Cells(i, 9).Text
    End If
    Next
    End sub

    I have copied and pasted the code and changed JAN to FEB, MAR etc.
    Last edited by adam1992; 12-15-2020 at 06:43 AM. Reason: Solved

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. VBA Code to search across all worksheets in a workbook
    By jjward101 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-22-2020, 04:01 PM
  2. [SOLVED] Code to search Excel and return results even if part of search text is present
    By Taoyuan00 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-30-2016, 09:20 AM
  3. Debug Code to Search Entire Workbook
    By atwy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-27-2014, 05:09 AM
  4. VBA Code - Search text & search number & search qty and result - Urgent Please
    By naresh73 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-15-2014, 10:51 AM
  5. Replies: 1
    Last Post: 10-18-2012, 05:52 AM
  6. [SOLVED] Fixing code for search engine for whole workbook
    By brownie4321 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-03-2012, 09:55 PM
  7. [SOLVED] Macro ignores search code when 1 of the 2 search parameters is not found
    By BrodyNoochie in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-25-2012, 05:21 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