Consulting

Results 1 to 4 of 4

Thread: Solved: Application or object based error

  1. #1
    VBAX Regular
    Joined
    Sep 2012
    Posts
    11
    Location

    Solved: Application or object based error

    Hello All,

    I am trying to create a "user friendly" invoice for a mates business. It relies on the user entering several paramaters (name, address etc) and putting them in a pre-formatted worksheet (see attached document). the user will enter the number of items being ordered, and then the following procedure will allow the user to select the respective objects and quantity:

    [VBA]Private Sub CommandButton1_Click()
    Dim formula As String
    Dim ws As Worksheet
    Set ws = Worksheets("Sheet4")
    row = 21
    col = 1
    On Error Resume Next
    Do
    If Items_entered <> Items Then

    quantity = ComboBox2.Value
    prod_desc = ComboBox1.Value
    Cells(row, col).Value = quantity
    col = col + 1
    Cells(row, col).Value = prod_desc
    Cells(row, col).Select
    varlookup = ActiveCell.Address
    col = col + 1
    Cells(row, col).Select
    Cells(row, col).Value = Application.WorksheetFunction.VLookup(prod_desc, Worksheets("Sheet4").Range(a2, b50), 2, False) '<<<<<< Here is where im getting my error
    col = col + 1
    Cells(row, col).Value = Cells(row, col - 1).Value * quantity
    UserForm1.Hide
    MsgBox ("item Added to Invoice")
    row = row + 1
    col = 1
    Items_entered = Items_entered + 1
    End If
    UserForm1.Show
    Loop Until Items_entered = Items
    End Sub[/VBA]

    i am having trouble with putting a Vlookup formula into a cell. im getting the "application or object based" runtime error.

    if anyine could shed some light on where i am going wrong, and a possible solution, i would be extremely greatful!!!
    Attached Files Attached Files

  2. #2
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    What is the line that fails?

  3. #3
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    In

    [vba]
    Cells(row, col).Value = _
    Application.WorksheetFunction.VLookup(prod_desc, Worksheets("Sheet4").Range(a2, b50), 2, False) _
    '<<<<<< Here is where im getting my error
    [/vba]

    you probably want

    [vba]
    .Range("a2:b50")
    [/vba]

    with the quotes and the colon

    Paul

  4. #4
    VBAX Regular
    Joined
    Sep 2012
    Posts
    11
    Location
    Thank You Very Much!!!

    i can believe it was something so simple

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •