Results 1 to 4 of 4

Refresh an already declared variable

Threaded View

  1. #1
    Forum Contributor
    Join Date
    10-30-2014
    Location
    England
    MS-Off Ver
    2007 / 365
    Posts
    279

    Refresh an already declared variable

    I have a macro in a master file which opens other smaller files and copies their data, it then moves these smaller files into a 'Done' folder with the current date and time appended to the file name.

    Currently I have declared my DateTime variable at the start of the code before my For Each loop gets to work on the files. This means that the the same Time (hhmmss) is appended to each file. Now I assume I could just rearrange the code so the declaration is inside the loop so the Time variable (or at least the seconds) would be updated for each file, but is that the only way to get the different times on each file, or is there some sort of 'refresh' line I can add to the start of the loop that will update the variable value instead?

    And on a related note, what is 'best practice' for declaring variables? Should they ideally all be declared at the start of the code or does it make no difference when or where you declare them (pending their usage obviously)?
    Last edited by EchoPassenger; 09-18-2016 at 04:13 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Variable declared as long out as text
    By marreco in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-05-2013, 09:06 AM
  2. [SOLVED] Global variable declared in Userform. Variable value is not sticking
    By timtim89 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-25-2012, 08:50 AM
  3. Non-declared variable
    By mqdias in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-20-2007, 10:01 AM
  4. [SOLVED] Refresh Query based on variable
    By GregR in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-21-2006, 06:25 PM
  5. [SOLVED] variable not declared error & syntax error
    By G. Beard in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-06-2005, 05:05 PM
  6. Help on combining declared variable and cell formula
    By sylink in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-12-2005, 06:05 PM
  7. [SOLVED] Help on combining declared variable and cell formula
    By sylink in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-12-2005, 03:05 PM

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