Need help modifying a macro made in 2003 for 2007

rupert123

New Member
Joined
Sep 7, 2011
Messages
1
I have a work book that was created with Excel 2003, but it no longer functions the way it was designed now that all of our computers were upgraded to Office 2007. The purpose of the work book is to keep track of daily munitions expenditures. Due to the strict permissions on government computers, I'm not allowed to change any of the trust center settings, so the easy fix of adding trusted sources/editors is no good.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
<o:p></o:p>
The basic idea for the work book is that the first tab holds all the data and then there are 31 tabs following that; one for each day of the month. The macro fills in the aircraft information into the day page when I enter the aircraft number into a cell. My problem is that the macro runs every single time the work book is opened, in all 31 day tabs instead of only activating when the information is requested. This causes problems, because I need to maintain a record of each day's expenditures for the whole month. I would like to have the macro function only when the aircraft number is inserted into the cell, and no other time.<o:p></o:p>
<o:p></o:p>
I'm hoping that someone might have a fairly simple solution, or know where I can go to learn how to make a work-a-round for this myself. I don't know very much about VBA, and I'm not even sure if what I'm asking for is possible.<o:p></o:p>
<o:p></o:p>
Below is the code that I need to modify. I feel like the solution should be fairly simple, but I don't understand much of anything after the Function FIndPart line. Any help would be greatly appreciated.<o:p></o:p>
<o:p></o:p>
<o:p></o:p>
Code:
 <o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]'This Function is the Main Lookup for the Entire Workbook.  It Receives an Aircraft
'Number from the Calling Cell, and that Cells Column & Level in Relation to that Aircraft.
'The Function Searches the "Data" Sheet for the Aircraft, then Sends Back the Cell in
'Relation to the Calling Cell.  If the Aircraft is Anything Other than an Actual Aircraft
'on the "Data" Sheet, it will Return Blank.<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]Function FindPart(Jet, Column, Level) As Object
Dim LineNumber As Integer
Dim Found As Boolean
Found = False
If Jet > 0 Then
    For XLoop = 5 To 157 '157 corresponds to the Number of rows on the Data Sheet
        If Sheets("DATA").Cells(XLoop, 2).Value = Jet Then
            Found = True
            LineNumber = XLoop
            XLoop = 157
        Else
            XLoop = XLoop + 3
        End If
    Next XLoop
    If Found Then
        Set FindPart = Sheets("DATA").Cells(LineNumber + Level, Column - 1)
    End If
End If<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]If Not Found Then
    Set FindPart = Sheets("DATA").Cells(1, 10)
End If<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]End Function<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]
<o:p></o:p>

<o:p> </o:p>
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

Forum statistics

Threads
1,224,584
Messages
6,179,693
Members
452,938
Latest member
babeneker

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top