+ Reply to Thread
Results 1 to 9 of 9

Producing sales history on point of sale

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    07-06-2020
    Location
    zimbabwe
    MS-Off Ver
    Excel 365
    Posts
    478

    Producing sales history on point of sale

    Hi

    I'm kindly requesting for excel formula to produce sales history (in the SALES HISTORY WORKSHEET) and also that when I print the invoice it automatically save the invoice transactions in the sales history, and moves to he next invoice. It should automatically insert invoice numbers staring starting from 1. It should refuse to print when the name of cashier and the amount received is not entered.

    Thank you
    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,359

    Re: Producing sales history on point of sale

    You will need VBA to do this as you require to effectively "paste values" in the Sales History sheet for every invoice.

    Also the last Invoice Number will need to be recorded, either as value in (say) "Point of Sale" or determined by the last Invoice in the "Sales History" sheet.

    Is the Invoice to be recorded (stored) and then printed as a PDF file?
    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
    07-06-2020
    Location
    zimbabwe
    MS-Off Ver
    Excel 365
    Posts
    478

    Re: Producing sales history on point of sale

    Hi

    VBA is welcome. I wish all the invoices printed to be pasted to and stored in the Sales History worksheet so that I able to compute tax and produce financial reports at the end financial period.. The print function should work as print and save at the same time. The reason is that the cashier can print and not saved the document as a result fraud can be easy to commit.

    Thank you.

  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,359

    Re: Producing sales history on point of sale

    Option Explicit
    Dim PDFName As String
    Sub Main()
        SALES_HISTORY
        Call PRINT_PAGE_PDF
    End Sub
    
    Sub SALES_HISTORY()
    
    Dim ws As Worksheet
    Dim Inv_Data, Hist_Data
    Dim Cashier As String
    Dim Invoice_Number As Long, lr As Long, i As Long, j As Long
    Dim Cash_Received As Double
    Dim Inv_Date As Date
    
    Application.ScreenUpdating = False
    
    Set ws = Sheets("Sales History")
    
    ReDim Hist_Data(1 To 40, 1 To 8)
    
    Const Invoice_Reference As String = "Invoice_"   '<<< Change to required Invoice reference
    
    With Sheets("Point of Sale")
    
        lr = .Cells(Rows.Count, "I").End(xlUp).Row
        Inv_Data = .Range("H18:O" & lr)
        Inv_Date = Int(.[J8]): Cashier = .[J9]: Cash_Received = .[E12]
        
        If Cashier = "" Or Cash_Received = 0 Then
            MsgBox "Cashier and/or Cash Received data missing" & vbCrLf & " Run terminated", vbCritical
            Exit Sub
        End If
        
        Invoice_Number = .[E18] + 1      ' Add 1 to "Last Invoice Number"
        .[L11] = Invoice_Number
        
        For i = 1 To UBound(Inv_Data)     ' Update "Sales History" data
            If Inv_Data(i, 1) = "" Then Exit For
            Hist_Data(i, 1) = Invoice_Number: Hist_Data(i, 2) = Inv_Date: Hist_Data(i, 3) = Cashier:
            Hist_Data(i, 4) = Inv_Data(i, 1): Hist_Data(i, 5) = Inv_Data(i, 2): Hist_Data(i, 6) = Inv_Data(i, 3)
            Hist_Data(i, 7) = Inv_Data(i, 5): Hist_Data(i, 8) = Inv_Data(i, 8)
        Next i
        
    .[E18] = Invoice_Number                ' re-set "Last Invoice Number"
        
    End With
    
    
    With ws                                ' Update "Sales History"
        lr = .Cells(Rows.Count, "A").End(xlUp).Row
        .Cells(lr + 1, "A").Resize(UBound(Inv_Data), 8) = Hist_Data
        .Columns(6).Resize(, 3).NumberFormat = "#,0.00"
    End With
    
    PDFName = Invoice_Reference & Format(Invoice_Number, "0000")  ' Set PDF name
    
    Application.ScreenUpdating = True
    
    
    End Sub
    Sub PRINT_PAGE_PDF()
    
        Application.ScreenUpdating = False
        Application.Calculation = xlCalculationManual
        Dim PDFPath As String
        
        PDFPath = "C:\Users\johnt\OneDrive\Desktop\pdf\" & PDFName & ".pdf" ' Set the desired PDF file path
    
        With ActiveSheet.PageSetup
            .PrintArea = "$G$1:$L$56"
        End With
    
        ' Export the active sheet as PDF
        ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=PDFPath, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False
    
        Application.Calculation = xlCalculationAutomatic
        Application.ScreenUpdating = True
        
    End Sub

    "Print PDF" updates the "Sales History" and then creates a PDF file
    Attached Files Attached Files
    Last edited by JohnTopley; 03-27-2024 at 12:08 PM.

  5. #5
    Forum Contributor
    Join Date
    07-06-2020
    Location
    zimbabwe
    MS-Off Ver
    Excel 365
    Posts
    478

    Re: Producing sales history on point of sale

    Hi

    Thank you so much for the VBA. Let me test the POS and come back to you if I encounter challenges.

    Thanks again.

  6. #6
    Forum Contributor
    Join Date
    07-06-2020
    Location
    zimbabwe
    MS-Off Ver
    Excel 365
    Posts
    478

    Re: Producing sales history on point of sale

    Hi

    When I click print the document is not printing but it displays 'Run-time error. Document not saved. The document may be open or error have encountered when saving".

  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,359

    Re: Producing sales history on point of sale

    Option Explicit
    Dim PDFName As String, abort As Boolean
    Sub Main()
        SALES_HISTORY
        If Not abort Then Call PRINT_PAGE_PDF
    End Sub
    
    Sub SALES_HISTORY()
    
    Dim ws As Worksheet
    Dim Inv_Data, Hist_Data
    Dim Cashier As String
    Dim Invoice_Number As Long, lr As Long, i As Long, j As Long
    Dim Cash_Received As Double
    Dim Inv_Date As Date
    
    Application.ScreenUpdating = False
    
    Set ws = Sheets("Sales History")
    
    ReDim Hist_Data(1 To 40, 1 To 8)
    abort = False
    
    Const Invoice_Reference As String = "Invoice_"   '<<< Change to required Invoice reference
    
    With Sheets("Point of Sale")
    
        lr = .Cells(Rows.Count, "I").End(xlUp).Row
        Inv_Data = .Range("H18:O" & lr)
        Inv_Date = Int(.[J8]): Cashier = .[J9]: Cash_Received = .[E12]
        
        If Cashier = "" Or Cash_Received = 0 Then
            MsgBox "Cashier and/or Cash Received data missing" & vbCrLf & " Run terminated", vbCritical
            abort = True
            Exit Sub
        End If
        
        Invoice_Number = .[E18] + 1      ' Add 1 to "Last Invoice Number"
        .[L11] = Invoice_Number
        
        For i = 1 To UBound(Inv_Data)     ' Update "Sales History" data
            If Inv_Data(i, 1) = "" Then Exit For
            Hist_Data(i, 1) = Invoice_Number: Hist_Data(i, 2) = Inv_Date: Hist_Data(i, 3) = Cashier:
            Hist_Data(i, 4) = Inv_Data(i, 1): Hist_Data(i, 5) = Inv_Data(i, 2): Hist_Data(i, 6) = Inv_Data(i, 3)
            Hist_Data(i, 7) = Inv_Data(i, 5): Hist_Data(i, 8) = Inv_Data(i, 8)
        Next i
        
    .[E18] = Invoice_Number                ' re-set "Last Invoice Number"
        
    End With
    
    
    With ws                                ' Update "Sales History"
        lr = .Cells(Rows.Count, "A").End(xlUp).Row
        .Cells(lr + 1, "A").Resize(UBound(Inv_Data), 8) = Hist_Data
        .Columns(6).Resize(, 3).NumberFormat = "#,0.00"
    End With
    
    PDFName = Invoice_Reference & Format(Invoice_Number, "0000")  ' Set PDF name
    
    Application.ScreenUpdating = True
    
    
    End Sub
    Sub PRINT_PAGE_PDF()
    
        Application.ScreenUpdating = False
        Application.Calculation = xlCalculationManual
        Dim PDFPath As String
        
        PDFPath = "C:\Users\johnt\OneDrive\Desktop\pdf\" & PDFName & ".pdf" ' Set the desired PDF file path
    
        With ActiveSheet.PageSetup
            .PrintArea = "$G$1:$L$56"
        End With
    
        ' Export the active sheet as PDF
        ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=PDFPath, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False
    
        Application.Calculation = xlCalculationAutomatic
        Application.ScreenUpdating = True
        
    End Sub
    Code updated to cater for error condtion is "Point of Sale" i.e Cashier and/or Cash Received" data missing.

    Re the rror: Impossible to say without knowing what data you entered.

    Did you change the path:

    PDFPath = "C:\Users\johnt\OneDrive\Desktop\pdf\" & PDFName & ".pdf" ' Set the desired PDF file path
    Attached Files Attached Files
    Last edited by JohnTopley; 03-27-2024 at 12:08 PM.

  8. #8
    Forum Contributor
    Join Date
    07-06-2020
    Location
    zimbabwe
    MS-Off Ver
    Excel 365
    Posts
    478

    Re: Producing sales history on point of sale

    Hi

    It is still not working. How do I change the path? I just saved the document as Excel Mcro-enabled workbook.

    Thank you.

  9. #9
    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,359

    Re: Producing sales history on point of sale

    The path points to a folder (say on the desktop) where you are going to save the PDF files.

    Create a folder on your desktop called PDF (or any name of your choosing) , then right click on the folder icon, click "Show more options", click " Properties" and "Location" is the path

    Copy/paste "Llocation" into the macro as shown in my previous post

    For me, "Location" for a folder called PDF on my desktop is "C:\Users\johnt\OneDrive\Desktop" so

    PDFPath is "C:\Users\johnt\OneDrive\Desktop\PDF\ " & PDFName & ".pdf"

    Hope this helps

+ 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. Creating a Point of Sale System in Excel
    By philbond in forum Excel General
    Replies: 4
    Last Post: 02-19-2022, 07:32 AM
  2. Point of sale and Excel
    By sheetalkamble in forum Excel General
    Replies: 0
    Last Post: 05-05-2021, 07:20 AM
  3. Point of Sale using microsoft excel
    By ranuj in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-15-2016, 02:09 AM
  4. Point of sale
    By Steamellar in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-10-2013, 02:18 PM
  5. [SOLVED] define exact number of products sale from multiple sale and returned sale orders
    By maabadi in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-05-2012, 06:14 AM
  6. Simple Point of Sale Solution in Excel
    By ahsanzafar in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-10-2012, 03:57 PM
  7. Excel & Point of Sale
    By busnut in forum Excel General
    Replies: 0
    Last Post: 08-04-2009, 07:24 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