I'm trying to write a function that can be called by other functions, but i'm having trouble passing variables to it the orderStuff function would be called by many different command buttons. I need to pass the Tag property of the command button to the orderStuff Function. The itemLoc variable in orderStuff, never contains the value of the Tag property from the command button.
Private Sub CommandButton1_Click()
Dim itemLoc As Integer
itemLoc = CommandButton1.Tag
Call orderStuff
End Sub
Private Sub orderStuff()
Dim menuItem As String
Dim itemPrice As String
menuItem = WorksheetFunction.VLookup(itemLoc, Sheets("Items").Range("itemNumbers"), 2)
itemPrice = WorksheetFunction.VLookup(itemLoc, Sheets("Items").Range("itemNumbers"), 3)
With Range("K5")
.Insert Shift:=xlDown
.Value = menuItem
End With
With Range("L5")
.Insert Shift:=xlDown
.Value = itemPrice
End With
End Sub
Bookmarks