Results 1 to 4 of 4

How can I make this code shorter by using Lookup and goto functions cause im really new

Threaded View

  1. #1
    Registered User
    Join Date
    03-06-2014
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    6

    How can I make this code shorter by using Lookup and goto functions cause im really new

    Sub buyme()
    Dim a As Integer
    Dim b As Integer
    Dim c As String
    Dim d As String
    Dim e As Integer
    Dim f As Integer
    Dim g As Integer
    Dim h As Integer
    Dim j As Integer
    Dim i As Integer
    Dim k As Integer
    Do
    a = Application.InputBox("Enter Item Number", "Item Code", 0)
    If a = Range("A2") Then
    b = Application.InputBox("Enter Item Quantity", "Lenovo Vibe X", 0)
    d = MsgBox("Price: " & Range("C2"), vbOKOnly)
    ElseIf a = Range("A3") Then
    b = Application.InputBox("Enter Item Quantity", "Samsung Galaxy Mega", 0)
    d = MsgBox("Price: " & Range("C3"), vbOKOnly)
    ElseIf a = Range("A4") Then
    b = Application.InputBox("Enter Item Quantity", "Sony Xperia 21", 0)
    d = MsgBox("Price: " & Range("C4"), vbOKOnly)
    ElseIf a = Range("A5") Then
    b = Application.InputBox("Enter Item Quantity", "LG Nexus", 0)
    d = MsgBox("Price: " & Range("C5"), vbOKOnly)
    ElseIf a = Range("A6") Then
    b = Application.InputBox("Enter Item Quantity", "HTC One Max", 0)
    d = MsgBox("Price: " & Range("C6"), vbOKOnly)
    ElseIf a = Range("A7") Then
    b = Application.InputBox("Enter Item Quantity", "Huawei Ascend P6", 0)
    d = MsgBox("Price: " & Range("C7"), vbOKOnly)
    ElseIf a = Range("A8") Then
    b = Application.InputBox("Enter Item Quantity", "Blackberry Q10", 0)
    d = MsgBox("Price: " & Range("C8"), vbOKOnly)
    ElseIf a = Range("A9") Then
    b = Application.InputBox("Enter Item Quantity", "MSI Primo", 0)
    d = MsgBox("Price: " & Range("C9"), vbOKOnly)
    ElseIf a = Range("A10") Then
    b = Application.InputBox("Enter Item Quantity", "Samsung Galaxy Note 8.0", 0)
    d = MsgBox("Price: " & Range("C10"), vbOKOnly)
    ElseIf a = Range("A11") Then
    b = Application.InputBox("Enter Item Quantity", "Huawei Media Pad 10 Link", 0)
    d = MsgBox("Price: " & Range("C11"), vbOKOnly)
    End If
    If a = Range("A2") Then
    i = b * Range("C2")
    ElseIf a = Range("A3") Then
    i = b * Range("C3")
    ElseIf a = Range("A4") Then
    i = b * Range("C4")
    ElseIf a = Range("A5") Then
    i = b * Range("C5")
    ElseIf a = Range("A6") Then
    i = b * Range("C6")
    ElseIf a = Range("A7") Then
    i = b * Range("C7")
    ElseIf a = Range("A8") Then
    i = b * Range("C8")
    ElseIf a = Range("A9") Then
    i = b * Range("C9")
    ElseIf a = Range("A10") Then
    i = b * Range("C10")
    ElseIf a = Range("A11") Then
    i = b * Range("C11")
    End If
    k = k + i
    c = MsgBox("Another", vbYesNo)
    Loop While c = vbYes
    If c = vbNo Then
    e = MsgBox("Total Price: " & k, vbOKOnly)
    g = Application.InputBox("Payment", vbOKOnly)
    j = g - k
    h = MsgBox("Change: " & j, vbOKOnly)
    End If
    End Sub
    Last edited by romarkevinruiz; 03-10-2014 at 05:07 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] How can I make this code shorter by using a loop. or there's any easier shorcuts code
    By romarkevinruiz in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-10-2014, 08:53 AM
  2. Is there a way to make my code shorter?
    By Angelfish13 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-05-2013, 01:23 PM
  3. Make VBA code shorter
    By juanrmz24 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-25-2013, 12:11 PM
  4. [SOLVED] how to make a long line of VBA code shorter...
    By minifreak in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-11-2012, 12:02 PM
  5. Make code shorter
    By Aquila in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-17-2010, 11:09 PM

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