+ Reply to Thread
Results 1 to 7 of 7

Problem with nested for and counters

  1. #1
    Registered User
    Join Date
    10-22-2015
    Location
    Mexico
    MS-Off Ver
    2013
    Posts
    15

    Question Problem with nested for and counters

    The problem I have can be found in the following workbook:
    In worksheet "tabla" there's a button called "Reporte semanal"
    You can type either Agosto or Septiembre in the first inputbox, then 2015 in the second one. With "Agosto" the program runs well, but in "Septiembre" it gives some random blank rows. I want to fix this before adding more information to the table. The problem is probably in the nested fors with the counters in the code (variable c), but I cant figure out what the problem is. Also if you have any suggestions to make what Im trying to do with my code better, feel free to tell me. It would be great.
    Thanks a lot for your time!
    Attached Files Attached Files

  2. #2
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    365 Version 2409
    Posts
    2,789

    Re: Problem with nested for and counters

    it gives some random blank rows
    After running it with both, August/Agosto and September/Septiembre these blank rows don't jump out at me.
    How about telling us specifically where one of these blank rows is and give us some details as to why it should not be blank.
    By details I mean specific details. Point us to where in the table the information is that should be in the blank row and explain why.
    Last edited by skywriter; 10-22-2015 at 06:04 PM.

  3. #3
    Registered User
    Join Date
    10-22-2015
    Location
    Mexico
    MS-Off Ver
    2013
    Posts
    15

    Re: Problem with nested for and counters

    Hello skywriter, thanks for taking your time. For example, in Agosto, in sheet "Informe semanal" spaces in rows 16, 32,47, 59, 71, 83 and so on are desired. But in septiembre, blank rows 24,25, 36,37 ,42, 159,184 are not desired. I dont know why it causes this on Septiembre, it should follow the same format Agosto gives. So when I add more data on "tabla", it keeps doing what I want the program to do. Feel free to check the code and make the suggestions you can. Thanks again and have a great evening.

  4. #4
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    365 Version 2409
    Posts
    2,789

    Re: Problem with nested for and counters

    By details I mean specific details. Point us to where in the table the information is that should be in the blank row and explain why.
    Again I don't know what is supposed to be in those blank rows, so again can you explain to me specifically what should be in what rows and why that information should be in those rows. To just tell me I don't desire a blank row here or there when I don't understand your worksheet doesn't help me.

    There should be a value that's supposed to be there. What is that value, where does it come from and why does it belong there?

    What part of your code is adding that value?
    I can't help you if you don't help me to help you.

  5. #5
    Registered User
    Join Date
    10-22-2015
    Location
    Mexico
    MS-Off Ver
    2013
    Posts
    15

    Re: Problem with nested for and counters

    Hello, the undesired blank rows shouldnt even appear, the code shouldnt, for example in Agosto, the report obtained is the following

    Tuxpan
    CTT Ventana
    GSR-C
    GSP-RP
    GSP-C
    MTBE
    GSRUBAZMVM
    CTT 17/08/201519/08/2015
    CTT 29/07/201531/07/2015
    CTT -
    CTT 02/09/201504/09/2015
    GSRUBAZMM
    GSPUBAZMVM
    GASOLINE BLENDSTOCK
    TERCERIAS

    Excel looks for every Puerto, each different products, if theres info about the product like CTT and the other this, it should be displayed right under the product. If there is no information in the table it should put the next product and so on for every product. The products are
    GSR-C
    GSP-RP
    GSP-C
    MTBE
    GSRUBAZMVM
    GSRUBAZMM
    GSPUBAZMVM
    GASOLINE BLENDSTOCK
    TERCERIAS

    When we ask the report for Septiembre, we get the following:
    Tuxpan
    CTT Ventana Buquetanque
    GSR-C
    GSP-RP
    GSP-C
    MTBE
    GSRUBAZMVM


    CTT - C
    CTT 02/09/201504/09/2015 A
    GSRUBAZMM
    GSPUBAZMVM
    GASOLINE BLENDSTOCK
    TERCERIAS

    the report instead should look like this:
    Tuxpan
    CTT Ventana Buquetanque
    GSR-C
    GSP-RP
    GSP-C
    MTBE
    GSRUBAZMVM
    CTT - C
    CTT 02/09/201504/09/2015 A
    GSRUBAZMM
    GSPUBAZMVM
    GASOLINE BLENDSTOCK
    TERCERIAS

    after each Puerto (like Tuxpan, Pajaritos) theres the desired blank row i was talking about
    Rosarito
    CTT Ventana
    GSR-C
    GSP-RP
    GSP-C
    MTBE
    GSRUBAZMVM
    GSRUBAZMM
    GSPUBAZMVM
    GASOLINE BLENDSTOCK
    TERCERIAS
    <------ here
    Lázaro Cárdenas
    CTT Ventana
    GSR-C
    GSP-RP
    GSP-C
    MTBE
    GSRUBAZMVM
    GSRUBAZMM
    GSPUBAZMVM
    GASOLINE BLENDSTOCK
    TERCERIAS

    The code that does this is the following:
    Please Login or Register  to view this content.
    I think the problem is where the nested for are with the counters of variable "c".
    I hope this explains better what the problem is. Thanks a lot!

  6. #6
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Problem with nested for and counters

    Please Login or Register  to view this content.
    in this piece of your code last posted
    i dont see the condition for month or year


    Kind regards
    Leo

  7. #7
    Registered User
    Join Date
    10-22-2015
    Location
    Mexico
    MS-Off Ver
    2013
    Posts
    15

    Re: Problem with nested for and counters

    You're right, sorry about that. Thanks.
    Kind regards

+ 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 counters and nested for
    By alexholly in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-30-2015, 11:15 AM
  2. [SOLVED] Conditional Counters
    By vicstone in forum Excel General
    Replies: 6
    Last Post: 09-18-2015, 01:24 PM
  3. How to create two counters
    By ammartino44 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-29-2015, 02:12 PM
  4. Need to setup 3 different counters
    By vicstone in forum Excel General
    Replies: 4
    Last Post: 05-18-2010, 10:59 PM
  5. Counters
    By halem2 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-30-2006, 04:59 PM
  6. INVOICE COUNTERS
    By omega25 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 11-16-2005, 06:25 PM
  7. [SOLVED] Counters
    By Paul in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-11-2005, 10:06 AM

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