I can't figure out how to get the fields to populate from the Invoice file..

phxsportz99

New Member
Joined
Sep 14, 2022
Messages
14
Office Version
  1. 2021
I've got this file that wants to get working file "TSC G - 001 Leadership Office.xlsx" to populate the fields of "INVOICE DATE", "INVOICE", "FROM", "TO", "BALANCE". The following are the Screen shots of the worksheets on the file.. I'm sorry, I've had a stroke so.. It's a little bit crappy but I hope you can figure it out..... ;)

"MASTER"
MASTER.xlsm
ABCDEF
1
2NEW
3
4Working File:TSC G - 001 Leadership Office.xlsx
5Invoice Date:The Sons Children
6INVOICE:TSC "G" - 001
7From:Valley Install's, L.L.C.
8To:The Sons Children
9
10Balance:$3,180.00
11
12
13
14
15
16
17
18
19
20
21
22EditCancel
23
24
25
MASTER
Cell Formulas
RangeFormula
C6:C7C6=Invoice!I4
C8C8=Invoice!B5
C10C10=Invoice!J41
Cells with Data Validation
CellAllowCriteria
C4:D4List='Working Folders'!$B$22:$B$70


"INVOICE"
TSC G - 001 Leadership Office.xlsx
ABCDEFGHIJK
1INVOICE
2
3Invoice Date:5/16/2023
4Invoice Number:TSC "G" - 001
5To:The Sons ChildrenFrom:Valley Install's, L.L.C.
62030 N 36th StreetRichard Hamilton
7Phoenix, AZ 850086441 W. Whitton Ave
8Phoenix, AZ 85033
9
10Trade:Demo / Install
11
12Comments Or Special Instructions:
13Demo Floor and do the install of flooringTerms:
14Due Upon
15Receipt
16
17Customer NameJobsite Address >2030 N 36th Street
18AustinPhoenix, AZ 85008
19Phone #602-956-7370Gate Code
20Description# of ItemsPriceAmount Due
21Demo Office1$ 750.00$750.00
22Flooring 552.25 Sq Ft + 10 Percent607.475$ 4.00$2,429.90
23 
24 
25 
26 
27 
28 
29 
30 
31 
32 
33 
34 
35 
36
37Misc.Sub Total: $3,179.90
38Miscellaneous:
39Total Due: $3,179.90
40Attachments:Deposit:
41Make All Checks Payable to: Balance: $3,179.90
42Valley Install's, LLCDate Paid:
Sheet1
Cell Formulas
RangeFormula
H22H22=(23.5*23.5*1.1)
J21:J35J21=IF(LEN(A21) <> 0,(H21*I21),"")
J37J37=SUM(J21:K35)
J39J39=SUM(J37+J38)
J41J41=J39-J40


"WORKING FOLDERS"
MASTER.xlsm
AB
59D:\Master\Building B\TSC OtherInvoice -TSC Laundry.xlsx
60D:\Master\Building B\TSC OtherInvoice -TSC U.L. #2 Paint.xlsx
61D:\Master\Building B\TSC OtherInvoice -TSC-2'sRmRePaint.xlsx
62D:\Master\Building B\UL Double DoorSons Children UC DD Demo.xlsx
63D:\Master\Building B\UL Double DoorSons Children UC DD Paint.xlsx
64D:\Master\Building B\UL Double DoorSons Children UC DD Wainscot.xlsx
65D:\Master\Building B\UL Next to KitchenSons Children UC NK DEMO.xlsx
66D:\Master\Building B\UL Next to KitchenSons Children UC NK PAINT.xlsx
67D:\Master\Building B\UL Next to KitchenSons Children UC NK Wainscot.xlsx
68D:\Master\Building B\UL Next to KitchenTSC B - 017 UC NK.xlsx
69D:\Master\Building G\Leadership OfficeTSC G - 001 Leadership Office.xlsx
70D:\Master\Building G\Staff BreakroomTSC G - 002 Staff Breakroom.xlsx
Working Folders


The "MASTER" file, "Working File" Is a Drop Down List..

Thanks... John
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Anything is possible but I would contain all of the information needed to generate an invoice in one or more
worksheets and generate the invoices from this information.

You could then access the information that you need from these sheets.

You are where you are though so I think that some code in the Worksheet Change event would work.

I'll see what I can do.
 
Upvote 0
One problem I have encountered is that one of the file names you have given has a ' character in it's name.

Invoice -TSC-2'sRmRePaint.xlsx

This is used by the INDEX function to look up the value from the file without it being open.

Is it possible to replace this character or remove it?
 
Upvote 0
I've come up with this.

Paste this code into the worksheet code module for the worksheet containing the Working File drop down validation list.

The worksheet containing the folder and file list needs to be called 'Working Folders' or change the reference to it on this line of code.
Set rngFound = Worksheets("Working Folders").Range("B:B").Find(strWorkingFile, LookIn:=xlValues)

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim strFormula As String
Dim strWorkingFile As String
Dim rngFound As Range
Dim strFolder As String
Dim strMsg As String

    ' On Error GoTo Err_Handler
    
    If Target.Count > 1 Then
        Exit Sub
    End If
                
    If Target = Range("C4") Then
    
        Range("C5:C10").Value = ""
        
        Application.ScreenUpdating = False
                
        strWorkingFile = Trim(Target.Value)
                        
        Set rngFound = Worksheets("Working Folders").Range("B:B").Find(strWorkingFile, LookIn:=xlValues)
        If rngFound Is Nothing Then
            Exit Sub
        End If
        
        strFolder = Trim(rngFound.Offset(0, -1) & "\")
        
        ' Check to see if the workbook actually exists.
        If Len(Dir(strFolder & strWorkingFile)) = 0 Then
            strMsg = "The invoice workbook '" & strWorkingFile & "' does not exist or has been saved in the incorrect folder."
            MsgBox strMsg, vbOKOnly, "Warning"
            Exit Sub
        End If
        
        ' Check to see if the workbook name contains a "'" character. (ASCII Code 39)
        ' This character is invalid as it is used a marker in the formula.
        If InStr(1, strWorkingFile, "'", vbTextCompare) > 0 Then
            strMsg = "The invoice workbook '" & strWorkingFile & "' contains an >> ' << character in the name." & vbCrLf & _
                "This is an invalid character." & vbCrLf & _
                "Please rename the file and edit the reference to it in the '" & "Working Folders" & "' worksheet."
            MsgBox strMsg, vbOKOnly, "Warning"
            Exit Sub
        End If
                                                        
        ' Invoice Date.
        With Range("C5")
            .Formula = "=INDEX('" & strFolder & "[" & strWorkingFile & "]Invoice'!I:I,3,1)"
            .NumberFormat = "dd/mm/yyyy"
        End With
        
        ' Invoice Number.
        Range("C6").Formula = "=INDEX('" & strFolder & "[" & strWorkingFile & "]Invoice'!I:I,4,1)"
        
        ' From.
        Range("C7").Formula = "=INDEX('" & strFolder & "[" & strWorkingFile & "]Invoice'!I:I,5,1)"
        
        ' To.
        Range("C8").Formula = "=INDEX('" & strFolder & "[" & strWorkingFile & "]Invoice'!B:B,5,1)"
        
        ' Balance.
        With Range("C10")
            .Formula = "=INDEX('" & strFolder & "[" & strWorkingFile & "]Invoice'!J:J,41,1)"
            .NumberFormat = "$#,##0.00"
        End With
        
    End If
    
Exit_Handler:
    
    Application.ScreenUpdating = True
    
    Exit Sub
    
Err_Handler:

    strMsg = "There has been an error." & vbCrLf & _
        "Number : " & Err.Number & vbCrLf & _
        "Description : " & Err.Description
        
    MsgBox strMsg
    
    Resume Exit_Handler

End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,215,094
Messages
6,123,071
Members
449,092
Latest member
ipruravindra

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top