Hi! So we recently switched form excel 2010 to 2016 (finally) and my macros are now working differently. I assume this may be a known issue, but I haven't been able to find the best info when searching online.
So here is the specific issue:
My macro is performing 3 actions I guess you could say. The way my macro was originally working in 2010 was it knew to stay on the same page and perform all 3 actions. However, now it seems as if it is jumping to the other tabs and trying to grab the information from those tabs instead. I have found that if I specifically tell the macro to go back to the "Chipping" tab by writing Sheet("CHIPPING").Select before each of the last 2 sections of my macro to copy range AH6:AT22 and copy range F12 then the macro works. Is it necessary to do this now in 2016 for all of my macros or is there something else going on that would be a better way to fix this. Below is the macro. Thank you in advance for any advice you can give me.
Sub Copy_Chipping_to_Summary_Tab()
'
' Copy_Chipping_to_Summary_Tab Macro
'
'
Dim WhatColumn As Long
Dim Summary As Worksheet
Dim Cel As Range
WhatColumn = 1 'Column A
NowColumn = 6
LastColumn = 11
Set Summary = Sheets("Summary")
Range("V5:Y16").Copy
If Summary.Cells(Rows.Count, WhatColumn).End(xlUp).Offset(2).Row > 57 Then
WhatColumn = NowColumn 'Now column E - next I
End If
If Summary.Cells(Rows.Count, NowColumn).End(xlUp).Offset(2).Row > 57 Then
WhatColumn = LastColumn
End If
Set Cel = Summary.Cells(Rows.Count, WhatColumn).End(xlUp).Offset(2)
Cel.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Cel.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Range("AH6:AT22").Copy
Set Cel = Sheets("DTS").Cells(Rows.Count, 1).End(xlUp).Offset(2)
Cel.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Cel.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Range("F12").Copy
Set Cel = Sheets("Notes").Cells(Rows.Count, 19).End(xlUp).Offset(1)
Cel.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End Sub
So here is the specific issue:
My macro is performing 3 actions I guess you could say. The way my macro was originally working in 2010 was it knew to stay on the same page and perform all 3 actions. However, now it seems as if it is jumping to the other tabs and trying to grab the information from those tabs instead. I have found that if I specifically tell the macro to go back to the "Chipping" tab by writing Sheet("CHIPPING").Select before each of the last 2 sections of my macro to copy range AH6:AT22 and copy range F12 then the macro works. Is it necessary to do this now in 2016 for all of my macros or is there something else going on that would be a better way to fix this. Below is the macro. Thank you in advance for any advice you can give me.
Sub Copy_Chipping_to_Summary_Tab()
'
' Copy_Chipping_to_Summary_Tab Macro
'
'
Dim WhatColumn As Long
Dim Summary As Worksheet
Dim Cel As Range
WhatColumn = 1 'Column A
NowColumn = 6
LastColumn = 11
Set Summary = Sheets("Summary")
Range("V5:Y16").Copy
If Summary.Cells(Rows.Count, WhatColumn).End(xlUp).Offset(2).Row > 57 Then
WhatColumn = NowColumn 'Now column E - next I
End If
If Summary.Cells(Rows.Count, NowColumn).End(xlUp).Offset(2).Row > 57 Then
WhatColumn = LastColumn
End If
Set Cel = Summary.Cells(Rows.Count, WhatColumn).End(xlUp).Offset(2)
Cel.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Cel.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Range("AH6:AT22").Copy
Set Cel = Sheets("DTS").Cells(Rows.Count, 1).End(xlUp).Offset(2)
Cel.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Cel.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Range("F12").Copy
Set Cel = Sheets("Notes").Cells(Rows.Count, 19).End(xlUp).Offset(1)
Cel.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End Sub