Today i tried running my macro and it is no longer working. It was working fine on Friday but it is giving me the wrong results now. I didn't change anything and I cant figure out why it is pulling the wrong data.
Here is my code which I think looks fine
Sub database()
Application.StatusBar = "It's Working..Relax."
On Error GoTo lblError
Dim bEvents As Boolean, iCalc As Integer, bScrnUpd As Boolean
bEvents = Application.EnableEvents
iCalc = Application.Calculation
bScrnUpd = Application.ScreenUpdating
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Dim rng As Range
Dim wbA As Workbook, wbB As Workbook
Set wbA = ThisWorkbook
Set wbB = Workbooks.Open("Z:\snv_pfm_commdrive\Sprint PFM\Mir Ali\Macro Enabled File\Sprint Database.xlsx")
With Sheets(4)
Set rng = Union(.Range("$J:$J"), .Range("$Q:$Q"), .Range("$AS:$AS"))
rng.Copy wbA.Sheets(3).Range("$B1")
wbB.Close
Sheets(3).Select
Call ConcatDB
Application.EnableEvents = bEvents
Application.Calculation = iCalc
Application.ScreenUpdating = bScrnUpd
Application.StatusBar = False
Exit Sub
'reset them even if you are exiting due to error
lblError:
Application.EnableEvents = bEvents
Application.Calculation = iCalc
Application.ScreenUpdating = bScrnUpd
Debug.Print Err.Description
End With
End Sub
Here is my code which I think looks fine
Sub database()
Application.StatusBar = "It's Working..Relax."
On Error GoTo lblError
Dim bEvents As Boolean, iCalc As Integer, bScrnUpd As Boolean
bEvents = Application.EnableEvents
iCalc = Application.Calculation
bScrnUpd = Application.ScreenUpdating
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Dim rng As Range
Dim wbA As Workbook, wbB As Workbook
Set wbA = ThisWorkbook
Set wbB = Workbooks.Open("Z:\snv_pfm_commdrive\Sprint PFM\Mir Ali\Macro Enabled File\Sprint Database.xlsx")
With Sheets(4)
Set rng = Union(.Range("$J:$J"), .Range("$Q:$Q"), .Range("$AS:$AS"))
rng.Copy wbA.Sheets(3).Range("$B1")
wbB.Close
Sheets(3).Select
Call ConcatDB
Application.EnableEvents = bEvents
Application.Calculation = iCalc
Application.ScreenUpdating = bScrnUpd
Application.StatusBar = False
Exit Sub
'reset them even if you are exiting due to error
lblError:
Application.EnableEvents = bEvents
Application.Calculation = iCalc
Application.ScreenUpdating = bScrnUpd
Debug.Print Err.Description
End With
End Sub