+ Reply to Thread
Results 1 to 2 of 2

change vba code from year to year

  1. #1
    Registered User
    Join Date
    10-28-2015
    Location
    BFE, USA
    MS-Off Ver
    2010
    Posts
    30

    change vba code from year to year

    I have some vba code that contains exact information that needs to be flexible. I've included a portion of code with a cell value below, but some vba references a file name or drive information with the year 2016.

    For i = 2 To lastRow
    If Cells(i, 8).Value = "2016" Then
    Cells(i, 1).Resize(1, 20).Interior.ColorIndex = 36
    End If
    Next i

    I would like to be able to change a specific word/number without manually accessing module and find/replacing all 2016.
    Is there another option?

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,321

    Re: change vba code from year to year

    I would normally create a "configuration" or "control" sheet and store that kind of variable information there. I usually define Named Ranges so that the structure of the configuration sheet is also flexible. Then you never touch the code.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How change cell year dates to automatically update to new year
    By RonRich in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-05-2015, 08:29 AM
  2. Automatically update year interval cycles from year to year
    By trumptight in forum Word Programming / VBA / Macros
    Replies: 8
    Last Post: 08-21-2014, 10:38 PM
  3. How Best to Plot Year on Year Change Using a Trendline?
    By JasonMcQueen in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 06-29-2014, 02:52 PM
  4. Change year but keep the month the same based on current year
    By Jamon Fries in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-11-2014, 05:29 PM
  5. Replies: 3
    Last Post: 09-04-2013, 10:49 AM
  6. VBA Code to detect change in fiscal year between dates
    By miam in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-25-2011, 03:33 AM
  7. [SOLVED] change the year in a calendar template to different year
    By George in forum Excel General
    Replies: 1
    Last Post: 07-19-2006, 02:34 PM

Tags for this Thread

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