Workbook open halts macro

benapark

New Member
Joined
Jan 26, 2015
Messages
1
I have a VBA macro in an excel. The macro opens another work inorder to copy a sheet into the active wookbook. When the open command executes the macro stops. I've tried this in and out of the debugger. I have tried several methods of coding the desired action (copy sheet from workbook into my active workbook). All versions stop on the workbook open call.

I even tried the submitted code MVP Bill Jelen on the MSDN stie.

Sub UpdateActualCosts()
'''''''''''''''''''''''''''
'''' NOT WORKING YET
'''''''''''''''''''''''''''
Dim HistoryRptLoc As String
Dim HistoryRptWookBook As String
Dim CostActualName As String
Dim ProjName As String
Dim HistWkBk As Workbook
Dim Criteria As String
Dim MaxDate As Integer
Dim MaxDateRng As Range
Dim iLastRow As Integer
Dim ControlFile As String

HistoryRptLoc = "\\\\mo-users\\\Financial\\"
HistoryRptWookBook = "FY2015 Labor History.xlsx"
CostActualName = "FY2015"

ThisWorkbook.Sheets("Project_Definition").Activate
ProjName = ActiveSheet.Range("Project_Definition!B2").Value

' open spreadsheet from remote location
ControlFile = ActiveWorkbook.Name
Workbooks.Open FileName:=HistoryRptLoc & HistoryRptWookBook
' the following code never executes - the file does open - it is a xlsx type file
ActiveSheet.Name = CostActualName
Sheets(CostActualName).Copy After:=Workbooks(ControlFile).Sheets("Performance")
Windows(HistoryRptWookBook).Activate
ActiveWorkbook.Close SaveChanges:=False
Windows(ControlFile).Activate
' get the max date in the first column
ThisWorkbook.Sheets(CostActualName).Activate
ActiveSheet.Select
ActiveSheet.Range("A1").Select
Selection.End(xlDown).Select
iLastRow = ActiveWindow.RangeSelection.Row
MaxDateRng = Range("A1:A" + CStr(iLastRow))
MaxDate = Application.WorksheetFunction.Max(MaxDateRng)
' filter for time and project
With Range("A1:H1")
.AutoFilter
.AutoFilter Field:=1, Criteria1:=CStr(MaxDate)
End With
' for each row in filtered range
' look up person - return rate
' AccumCharges += rate * hours
End Sub
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Forum statistics

Threads
1,223,630
Messages
6,173,456
Members
452,514
Latest member
cjkelly15

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