Results 1 to 3 of 3

calling functions

Threaded View

  1. #1
    Registered User
    Join Date
    09-13-2011
    Location
    NYC
    MS-Off Ver
    Excel 2003
    Posts
    9

    calling functions

    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
    Last edited by stevedomer; 09-15-2011 at 07:48 PM.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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