+ Reply to Thread
Results 1 to 3 of 3

Macro runs when I change cells in totally different sheet. Why?

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    05-24-2014
    MS-Off Ver
    Microsoft Office 2013
    Posts
    113

    Macro runs when I change cells in totally different sheet. Why?

    So I have a worksheet that has a lot of macros in it. I have just barely run into a problem that happens anytime a change a cell in another workbook that I have open. The second workbook I have open isn't even a macro enabled workbook. But for some reason it gives me an error and says I am trying to run this code.
    Private Sub ProductSelection_Click()
    Sheets("Transaction").Label2.Caption = Format(Sheets("Dummy").Range("LookupPrice").Value, "$###0.00")
    End Sub
    It gives me the runtime error 9. This code is supposed to run when I click on a combobox in my main workbook but it is running anytime I change something in my other simple workbook. Does anyone know why this happens and how to stop it? I have had a lot of similar problems in the past but I just dealt with it by only having one workbook open but in this case I will need both.

  2. #2
    Forum Contributor
    Join Date
    05-24-2014
    MS-Off Ver
    Microsoft Office 2013
    Posts
    113

    Re: Macro runs when I change cells in totally different sheet. Why?

    This is what I am trying now but it still doesn't work. When I declared the workbook within this private sub it worked great. I just want to make this a public function or whatever it takes so I can use the same text in all my macros without having to set it. This is what I have.
    Public InvManageWB As Workbook
    Public Sub workbookvariable()
        Dim InvManageWB As Workbook
        Set InvManageWB = Workbooks("Inventory Management DropBox.xlsm")
    End Sub
    
    Private Sub ProductSelection_Change()
    
    InvManageWB.Sheets("Transaction").Label2.Caption = Format(InvManageWB.Sheets("Dummy").Range("LookupPrice").Value, "$###0.00")
    End Sub

  3. #3
    Forum Contributor
    Join Date
    05-24-2014
    MS-Off Ver
    Microsoft Office 2013
    Posts
    113

    Re: Macro runs when I change cells in totally different sheet. Why?

    I figured it out. Here is my soluction
    Public Function InvManageWB() As Workbook
        Set InvManageWB = Workbooks("Inventory Management DropBox.xlsm")
    End Function
    
    Private Sub ProductSelection_Change()
    InvManageWB.Sheets("Transaction").Label2.Caption = Format(InvManageWB.Sheets("Dummy").Range("LookupPrice").Value, "$###0.00")
    End Sub
    As for why it was triggering the macro I still have no Idea.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Find last row and change it every time macro runs
    By tedy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-28-2013, 08:45 AM
  2. Worksheet Footer Notes Change when the macro runs.
    By vba_dev_88 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-12-2012, 01:49 PM
  3. Keyboard Cell Delete Runs Into Stack OverFlow With Sheet Change
    By Winon in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-01-2011, 06:30 PM
  4. Change cell value and macro runs
    By Macdave_19 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-23-2007, 04:18 AM
  5. Cell value change runs a macro?
    By Steach91 in forum Excel General
    Replies: 6
    Last Post: 06-18-2006, 03:20 PM

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