L
Legacy 287389
Guest
Hi good people!,
I have tried sooo much in getting this macro to work, but it simply refuses. When T2 is 2014, and I click the control, the code jumps to a: and executes. This part works fine. The problem is that when T2 is anything but 2014, for example 2015, the code is supposed to execute the first half of the entire code. It simply refuses. The screen gives a flicker, closes workbook "tables rev.xls", and that's it, nothing more. Please, if anyone would be so kind to shed some light on this for me, I will be un-explainably grateful...thank you very much..
I have tried sooo much in getting this macro to work, but it simply refuses. When T2 is 2014, and I click the control, the code jumps to a: and executes. This part works fine. The problem is that when T2 is anything but 2014, for example 2015, the code is supposed to execute the first half of the entire code. It simply refuses. The screen gives a flicker, closes workbook "tables rev.xls", and that's it, nothing more. Please, if anyone would be so kind to shed some light on this for me, I will be un-explainably grateful...thank you very much..
Code:
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Set ws1 = Sheets("database")
Set ws2 = Sheets("TABLES REV")
If Range("T2") = 2014 Then
GoTo a:
Else
With ws1.Cells(3, Columns.Count).End(xlToLeft).Offset(0, 1)
.Resize(3, 1).Value = ws2.Range("F3:F5").Value
End With
With ws1.Cells(8, Columns.Count).End(xlToLeft).Offset(0, 1)
.Resize(3, 1).Value = ws2.Range("F8:F10").Value
End With
With ws1.Cells(13, Columns.Count).End(xlToLeft).Offset(0, 1)
.Resize(3, 1).Value = ws2.Range("F13:F15").Value
End With
With ws1.Cells(18, Columns.Count).End(xlToLeft).Offset(0, 1)
.Resize(3, 1).Value = ws2.Range("G3:G5").Value
End With
With ws1.Cells(23, Columns.Count).End(xlToLeft).Offset(0, 1)
.Resize(3, 1).Value = ws2.Range("G8:G10").Value
End With
With ws1.Cells(28, Columns.Count).End(xlToLeft).Offset(0, 1)
.Resize(3, 1).Value = ws2.Range("G13:G15").Value
End With
Workbooks("Tables Rev.Xls").Activate
ActiveWorkbook.Close
Range("A1").Select
Set ws1 = Nothing
Set ws2 = Nothing
Range("A1").Select
Exit Sub
a:
With ws1.Cells(35, Columns.Count).End(xlToLeft).Offset(0, 1)
.Resize(3, 1).Value = ws2.Range("F3:F5").Value
End With
With ws1.Cells(40, Columns.Count).End(xlToLeft).Offset(0, 1)
.Resize(3, 1).Value = ws2.Range("F8:F10").Value
End With
With ws1.Cells(45, Columns.Count).End(xlToLeft).Offset(0, 1)
.Resize(3, 1).Value = ws2.Range("F13:F15").Value
End With
With ws1.Cells(50, Columns.Count).End(xlToLeft).Offset(0, 1)
.Resize(3, 1).Value = ws2.Range("G3:G5").Value
End With
With ws1.Cells(55, Columns.Count).End(xlToLeft).Offset(0, 1)
.Resize(3, 1).Value = ws2.Range("G8:G10").Value
End With
With ws1.Cells(60, Columns.Count).End(xlToLeft).Offset(0, 1)
.Resize(3, 1).Value = ws2.Range("G13:G15").Value
End With
Workbooks("Tables Rev.Xls").Activate
ActiveWorkbook.Close
Range("A1").Select
Set ws1 = Nothing
Set ws2 = Nothing
Range("A1").Select
End If
End Sub