Copy your code in a macro in a normal module and in the
Workbook_Open event in the thisworkbook module also call the macro
Private Sub Workbook_Open()
Call yourmacro
End Sub
Note:
Private Sub Worksheet_Change(ByVal Target As Range)
you must copy this into the sheet module
--
Regards Ron de Bruin
http://www.rondebruin.nl
"MaxRoberts22" wrote in message oups.com...
I have the following subroutines setup. I does not seem to execute my
macro when I execute the cell included in your macro. I should note
that my subroutine is contained in the "ThisWorkbook" module. Will that
make it a problem?
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Range("B33"), Target) Is Nothing Then
Call Workbook_Open
End If
End Sub
Public Sub Workbook_Open()
Dim wks1 As Worksheet
Dim wks2 As Worksheet
Dim Index As Worksheet
Dim Month As Integer
Dim Day As Integer
Dim PayDay1 As Integer
Dim PayDay1A As Integer
Dim PayDay2 As Integer
Dim UserDay As Integer
Dim UserMonth As Integer
Dim MonthInt As Integer
Dim StartCol As Integer
Dim EndCol As Integer
Dim Refrow As Integer
Set Index = Worksheets("Index")
Set wks1 = Worksheets("Paychecks & Deductions - 2006")
Set wks2 = Worksheets("CCs & Bank Accts. - 2006")
Month = wks1.Range("C1").Value
Day = wks1.Range("D1").Value
UserDay = Index.Range("C1").Value
UserMonth = Index.Range("D1").Value
wks2.Range("K2:DZ2").Select
Selection.EntireColumn.Hidden = True
MonthInt = 1
Refrow = 1
PayDay1 = Index.Cells(Refrow, 1).Value
PayDay1A = PayDay1 + 1
PayDay2 = Index.Cells(Refrow + 1, 1).Value
StartCol = 11
EndCol = 15
Do Until MonthInt 12
If UserDay <= PayDay1 And UserMonth = MonthInt Then
wks2.Range(Cells(2, StartCol), Cells(2, EndCol)).Select
Selection.EntireColumn.Hidden = False
Exit Do
Else
If UserDay PayDay1A And UserDay <= PayDay2 And UserMonth
= MonthInt Then
wks2.Range(Cells(2, StartCol + 5), Cells(2, EndCol +
5)).Select
Selection.EntireColumn.Hidden = False
Exit Do
Else
MonthInt = MonthInt + 1
Refrow = Refrow + 2
End If
End If
Loop
ActiveWorkbook.Save
End Sub