Results 1 to 3 of 3

Different VBA code dependant on year

Threaded View

SharpL Different VBA code dependant... 10-21-2014, 05:23 AM
SharpL Re: Different VBA code... 10-21-2014, 06:28 AM
JOHN H. DAVIS Re: Different VBA code... 10-21-2014, 07:02 AM
  1. #1
    Forum Contributor
    Join Date
    09-18-2014
    Location
    England
    MS-Off Ver
    2003/2010/365
    Posts
    119

    Lightbulb Different VBA code dependant on year

    Hi,

    I current have VBA coding in my worksheet, however I need to future proof for 2015.

    I haven't created my 2015 code yet, but my 2014 code is:

    Sub Macro1()
    '
    ' Macro1 Macro
    '
    
    '
        Range("D2").Select
        Selection.Copy
        Workbooks.Open Filename:= _
            "G:\<FileName>.xlsm"
        Range("D2").Select
        ActiveSheet.Paste
        Range("D3").Select
        Application.Goto Reference:="R5C1:R250000C34"
        Selection.Copy
        Windows("Contract Review - Master Doc.xlsm").Activate
        Range("A5").Select
        ActiveSheet.Paste
        Cells.Select
        Cells.EntireColumn.AutoFit
        Range("A1").Select
        Columns("B:B").ColumnWidth = 10.29
        Columns("C:C").ColumnWidth = 9
        Columns("D:D").ColumnWidth = 5.57
        Columns("C:C").ColumnWidth = 17.43
        Columns("B:B").ColumnWidth = 14.86
        Columns("C:C").ColumnWidth = 13.43
        Columns("D:D").ColumnWidth = 10.14
    
    Windows("Contract Extraction.xlsm").Activate
        ActiveWindow.Close
    
    End Sub
    I need a variable that says, if it's 2014, then use this code.

    However, if it's 2015, then use the 2015 code.

    Any help appreciated.

    Many thanks.
    Last edited by SharpL; 10-21-2014 at 05:46 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Run code dependant on what is written in a cell
    By forrestgump1980 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-04-2014, 10:06 AM
  2. Code for submit button to delete row dependant on combobox value
    By mezza89 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-04-2014, 10:01 AM
  3. dependant 4 dropdown lists vba code. Help pls
    By Milan Bhatia in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-20-2013, 08:55 AM
  4. Run Code With being dependant on sheet name (With activesheet)
    By djfatboyfats in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-05-2013, 09:56 AM
  5. Sum of year dependant on start month
    By scooterboygnu in forum Excel General
    Replies: 2
    Last Post: 09-19-2011, 10:41 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1