+ Reply to Thread
Results 1 to 3 of 3

Loop problem

  1. #1
    Registered User
    Join Date
    12-15-2014
    Location
    singapore
    MS-Off Ver
    2013
    Posts
    45

    Loop problem

    Hi guys,

    I wanted to do a vba loop where it writes

    20141101000000 which reads as [year][month][date] and time [24 hour format for every 3 hour]
    20141101030000
    20141101060000

    I wanted to stop my inner loop at 21000 hour and the bigger loop at 20141130

    here is how i write my code

    Please Login or Register  to view this content.
    but here is the result

    201411010
    2014110130000
    2014110160000
    2014110190000
    20141101120000
    20141101150000
    20141101180000
    20141101210000

    the bigger loop doest work
    and how do i show the 1st row do have another 4 zeroes?

    Thanks

  2. #2
    Forum Guru
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,877

    Re: Loop problem

    Hi,

    You must reset the value of "Time" variable before you use it again for the next inner loop.
    If you don't reset it, after the first inner loop, the "Time" variable value is always 210000, so the next loop will always be skipped.

    Please Login or Register  to view this content.
    To set the desired text format for the "Time", use the format() function like in above code.

    And I suggest, please do not use reserved keywords (like Month and Time) as variable name, it can give a lot of trouble.
    Change them to something like TheMonth, TheTime.

    Regards

  3. #3
    Forum Guru
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,450

    Re: Loop problem

    Please Login or Register  to view this content.

+ 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. Problem with loop
    By bobfoley91 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-24-2014, 02:21 PM
  2. Vlookup problem in a loop with cell property and variable cell problem (long title sry)
    By ExcelsiorLux in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-13-2013, 10:38 AM
  3. [SOLVED] Loop inside a loop problem!
    By questionguy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-22-2012, 12:54 PM
  4. [SOLVED] do until loop need help with this problem
    By carden2 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-03-2012, 04:52 PM
  5. Problem adding charts using Do-Loop Until loop
    By Chris Bromley in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-23-2005, 09:06 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