Macro code does not execute

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..
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
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
What is 2014 or 2015 ?
Part of a date, a number, text ??
 
Upvote 0
The original report I work from gives this as heading:
For Gaming Day Starting 01/05/2015

so, what I do is use in cell T1 =right(cell no, 10), to extract the date portion of this text. Then cell T2 has a =year(T1). I hope this helps..
 
Upvote 0
Maybe just to add, the cell T2 is formatted as number. I have tried "general" also, doesn't work..
 
Upvote 0
Michael!!..stop stop!!..I found it!!

Aw man!, I need to very humbly ask for your forgiveness...The code does execute the first half, the problem was that I had on the far right of the sheet added some other stuff, (datasheet), so the code was pasting to the right of all that, instead of pasting to the left of that but still to the right of the last date entry...I don't know if this makes sense to you now, but anyways, please accept my apology..I have sent you on a wild goose chase for nothing!!
 
Upvote 0
No worries....At least you got it solved....(y)
 
Upvote 0

Forum statistics

Threads
1,215,355
Messages
6,124,468
Members
449,163
Latest member
kshealy

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