+ Reply to Thread
Results 1 to 3 of 3

How to Reference a Loop Counter

  1. #1
    Registered User
    Join Date
    03-19-2018
    Location
    Goulburn
    MS-Off Ver
    MS Office Professional Plus 2016
    Posts
    35

    Question How to Reference a Loop Counter

    Hey everyone,


    I want to reference a loop in other functions because depending on the loop count it is up to depends on the row i want.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.


    I can't give a worksheet for this one as it is entangled with a database and would break the moment i removed it.


    pretty much if i go

    Please Login or Register  to view this content.
    It will tell me what loop it is up to, so i know that it is certainly increasing numbers


    But i can't reference it

    The moment i do

    Please Login or Register  to view this content.

    If i hover over CurrentActiveRow i get [Empty] and if i hover over CounterCar i get [1] or what ever loop it is up to


    I did have a code before this using select, it worked at first but i found it unreliable and just my computer dropping in speed could trip it up, if you have a better way of doing this i am open to ideas, i don't want to use select, speed is key but most important reliablity

    If you need more information i will do my best to provide

    Thanks


    Bensley

  2. #2
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: How to Reference a Loop Counter

    Hi,
    You can simply pass the number as an argument
    Please Login or Register  to view this content.
    I have highlighted the required changes. You would need to amend any other routines that use the variable too; or you could use a public or module level variable.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  3. #3
    Registered User
    Join Date
    03-19-2018
    Location
    Goulburn
    MS-Off Ver
    MS Office Professional Plus 2016
    Posts
    35

    Re: How to Reference a Loop Counter

    Not sure that will work with the overall code, I have changed the documents so that as longs as they are in the same folder they will work


    the code in question is under practices lists on the sheet interface, and is the "add to database" button, you don't need to open the database, it will auto do that
    i just had the extra button there so i could open it quick for editing


    the button asks for what practice list so you will need to choose '1' as there is only one, and then the date, enter what ever in date format, then will try to put
    the data on the database, but will fail. due to not referencing the counter



    i originally had another loop in there it was dodgey it is just in comments right now, i don't like using select and copy and all that


    Thanks

    Bensley

+ 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. Display a loop counter
    By TBurgum in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-12-2018, 04:10 PM
  2. [SOLVED] Reducing the value of a loop counter
    By danielexcelvba in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-08-2017, 12:29 PM
  3. Loop Macro with Counter
    By Ricky Wilko in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-18-2014, 07:33 AM
  4. For loop counter reset
    By amphinomos in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-03-2014, 10:59 AM
  5. [SOLVED] Counter in a loop
    By jonathanrgz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-11-2013, 05:46 PM
  6. loop counter not recognised
    By Dave H9 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-13-2011, 02:53 AM
  7. How can I avoid changing a loop counter within a loop?
    By broro183 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-26-2009, 07:59 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