+ Reply to Thread
Results 1 to 2 of 2

Calculate Inventory and number of items sold

Hybrid View

  1. #1
    Registered User
    Join Date
    11-30-2013
    Location
    Kingston, Cnada
    MS-Off Ver
    Excel 2003
    Posts
    2

    Calculate Inventory and number of items sold

    SOLVED see reply. I use a user form to fill in an invoice, the form consists of a drop down box for part numbers, a part description, labour price, retail price and qty sold
    I get a runtime error 1004 Application-defined or object defined error when the ok button is pressed and the Txt Box Qty is empty
    I use the attached code to fill in the invoice sheet from the user form when the ok button is clicked

    Private Sub CmdOK_Click()
    Dim R As Range
    Dim TbxQty As Long
    Set R = Sheets("Client Invoice").Range("A19:A36").End(xlUp)
    ActiveCell.Value = Me.CbxPartNo.Value
    ActiveCell.Offset(0, 1).Value = Me.Tbxdescription.Value
    ActiveCell.Offset(0, 10).Value = Me.TbxQty.Value
    ActiveCell.Offset(0, 11).Value = Me.TbxLabour.Value
    ActiveCell.Offset(0, 12).Value = Me.TbxRetail.Value
    
    'Reduce Inventory when item sold
    Sheets("Full Price List").Range("C" & CbxPartNo.ListIndex + 1).Value = Sheets("Full Price List").Range("C" & CbxPartNo.ListIndex + 1).Value - Me.TbxQty.Value
    'Add Qty to Qty Sold column
    Sheets("Full Price List").Range("I" & CbxPartNo.ListIndex + 1).Value = Sheets("Full Price List").Range("I" & CbxPartNo.ListIndex + 1).Value + Me.TbxQty.Value
    
    Unload Me
    
    msgboxyesno
    End Sub
    Last edited by rtfish; 03-11-2019 at 07:14 PM.

  2. #2
    Registered User
    Join Date
    11-30-2013
    Location
    Kingston, Cnada
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Calculate Inventory and number of items sold

    SOLVED. I had to define the TbxQty as a number, when the TbxQty box was blank it was considered a null string not 0. new code is below

    Private Sub CmdOK_Click()
    Dim R As Range
    Dim TbxQty As Long
    Set R = Sheets("Client Invoice").Range("A19:A36").End(xlUp)
    ActiveCell.Value = Me.CbxPartNo.Value
    ActiveCell.Offset(0, 1).Value = Me.Tbxdescription.Value
    ActiveCell.Offset(0, 10).Value = Me.TbxQty.Value
    ActiveCell.Offset(0, 11).Value = Me.TbxLabour.Value
    ActiveCell.Offset(0, 12).Value = Me.TbxRetail.Value
    
    If IsNumeric(Me.TbxQty.Value) Then
    new_Value = CDbl(Me.TbxQty.Value)
    Sheets("Full Price List").Range("C" & CbxPartNo.ListIndex + 1).Value = Sheets("Full Price List").Range("C" & CbxPartNo.ListIndex + 1).Value - Me.TbxQty.Value
    Sheets("Full Price List").Range("I" & CbxPartNo.ListIndex + 1).Value = Sheets("Full Price List").Range("I" & CbxPartNo.ListIndex + 1).Value + Me.TbxQty.Value
    
    Else
    new_Value = 0
    
    End If
    Unload Me
    
    msgboxyesno
    End Sub
    Last edited by rtfish; 03-11-2019 at 07:10 PM.

+ 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. Replies: 1
    Last Post: 03-16-2018, 12:52 PM
  2. getting total number of items sold from a list
    By rchapman in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-18-2014, 06:42 AM
  3. How to calculate average if a certain number of goods are sold
    By danieldaniel1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-06-2013, 05:44 PM
  4. Replies: 1
    Last Post: 07-02-2013, 09:17 PM
  5. [SOLVED] Need remaining average inventory price after partial inventory is sold
    By Akano in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-04-2012, 04:12 AM
  6. Calculationg number of items sold after a specific date
    By JohnFletcher66 in forum Excel General
    Replies: 3
    Last Post: 10-28-2011, 07:39 AM
  7. Counting the Number of Unique Items Sold by Each Salesperson
    By ExcelTip in forum Tips and Tutorials
    Replies: 0
    Last Post: 08-25-2005, 06:14 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