+ Reply to Thread
Results 1 to 2 of 2

Macros and Command Buttons

  1. #1
    Registered User
    Join Date
    04-20-2005
    Posts
    1

    Macros and Command Buttons

    I've never really programmed through Excel before, but I know Access a little so I got a new project tossed my way- I don't know VBA, but I'm sure this is a simple fix: I have two command buttons in a spreadsheet, and when either is clicked there are two macros that need to run. I'm getting "Sub or Function not defined." Forgive me for the crude hack attempts, but I'm so lost.... here's what I have.

    Private Sub CommandButton1_Click()
    Execute "jobaid!hidereconn"
    Execute "jobaid!newconn"
    End Sub


    Help!

  2. #2
    Registered User
    Join Date
    04-20-2005
    Posts
    7
    I'm not really the best at this sort of thing, but what works best for me is to copy the macro into the Sub. For instance, you'd have:

    Private Sub CommandButton1_Click()

    Rows("1:7").Select
    Selection.Delete Shift:=xlUp
    Columns("A:A").Select
    Selection.Delete Shift:=xlToLeft
    Range("A1").Select

    End Sub


    Hope this helps.
    Sam


    Quote Originally Posted by foxlme
    I've never really programmed through Excel before, but I know Access a little so I got a new project tossed my way- I don't know VBA, but I'm sure this is a simple fix: I have two command buttons in a spreadsheet, and when either is clicked there are two macros that need to run. I'm getting "Sub or Function not defined." Forgive me for the crude hack attempts, but I'm so lost.... here's what I have.

    Private Sub CommandButton1_Click()
    Execute "jobaid!hidereconn"
    Execute "jobaid!newconn"
    End Sub


    Help!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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