+ Reply to Thread
Results 1 to 19 of 19

Macro acts funny when more than 30 records are present

  1. #1
    Forum Contributor
    Join Date
    10-23-2004
    Location
    Los Angeles
    MS-Off Ver
    2010
    Posts
    253

    Question Macro acts funny when more than 30 records are present

    I have a macro that reorganizes data presented to me from a batch parameter query.

    If that query results in MORE THAN 30 records, then when i run THE MACRO IN QUESTION, only the 1st and last record get converted to how I want it.

    The attached excel macro file has the first 5 Examples OF where it wont work right. The next 2 examples show where it will work right. The last 2 examples show where it wont work (just like the 1st 5 examples), except that the last 2 examples (#8 and #9 examples), you can see what the macro gives me as the END result.

    A TRUE GOOD RESULT looks like the tab CSV GPS File.

    Why does the macro do this?
    The macro can be played on the button "Create CSV/GPS File" on the "GPS Extraction Template" tab.
    Attached Files Attached Files

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Macro acts funny when more than 30 records are present

    Hi,

    What's the macro in question? Is it the Create_CSV_Filev4() procedure or the DoBatchOfParam....

    Can you talk us through it explaining in narrative what you're expecting it to do with reference back to relevant sheets/ranges/criteria. I'm not entirely sure why you'd want to use a looping macro if the aim is to extract a subset of records which can be more easily and efficiently obtained with a data filter
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Contributor
    Join Date
    10-23-2004
    Location
    Los Angeles
    MS-Off Ver
    2010
    Posts
    253

    Re: Macro acts funny when more than 30 records are present

    Richard, sorry for not explaining it better.

    Yes I am talking about Create_CSV_Filev4().

    What I am achieving with limited success (as long as there isn't more than 30 rows of data), is gathering the data from B5:G33 (Which means 28 rows of data) from the tab GPS Extraction Template.

    The end result is the tab CSV GPS File. When there are too many rows of data appearing on GPS Extraction Template, the results look like the last 2 tabs (EX 8 and EX 9) from Column G to A. I put in several tab examples so that my error can be replicated. The current data on the first tab works succesfully (and many times it will, provided there isn't that many rows of data).

    I hope I didn't confuse you.

  4. #4
    Forum Contributor
    Join Date
    10-23-2004
    Location
    Los Angeles
    MS-Off Ver
    2010
    Posts
    253

    Re: Macro acts funny when more than 30 records are present

    Quote Originally Posted by Richard Buttrey View Post
    Hi,

    What's the macro in question? Is it the Create_CSV_Filev4() procedure or the DoBatchOfParam....

    Can you talk us through it explaining in narrative what you're expecting it to do with reference back to relevant sheets/ranges/criteria. I'm not entirely sure why you'd want to use a looping macro if the aim is to extract a subset of records which can be more easily and efficiently obtained with a data filter
    Richard, what do you think?

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Macro acts funny when more than 30 records are present

    Quote Originally Posted by JPWRana View Post
    Richard, what do you think?
    The question shouldn't be what do I think, rather what do you mean. Hence the question.

    Remember when it comes to stuff you live and breath on a daily basis it's all second nature to you and you know exactly what it should be doing. Furthermore we all write code in different ways and what you think is so obvious that the code syntax should be all the comment necessary, isn;t always so obvious to us - particularly in the absence of a workbook.

    So help us to help you.

  6. #6
    Forum Contributor
    Join Date
    10-23-2004
    Location
    Los Angeles
    MS-Off Ver
    2010
    Posts
    253

    Re: Macro acts funny when more than 30 records are present

    Richard, my fault. I quoted the wrong post. I meant to quote my answer to your FIRST question.

    What I meant to say is... What do you think of my explanation to your FIRST question on Post #3?

  7. #7
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Macro acts funny when more than 30 records are present

    Hello JPWRana,

    I rewrote the macro and tested it out. It works on the sample data with no adjustments. The other data that was not working will work with this macro provided you insert a column "A" for the "#". The macro can be adjusted to ignore this column if you like.

    Here is the rewritten macro code...
    Please Login or Register  to view this content.
    Last edited by Leith Ross; 01-11-2017 at 02:52 AM.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  8. #8
    Forum Contributor
    Join Date
    10-23-2004
    Location
    Los Angeles
    MS-Off Ver
    2010
    Posts
    253

    Re: Macro acts funny when more than 30 records are present

    Leith

    First of all, my apologies for the very delayed response. I never lost sight of the work you did, but my time shifted me away from responding to the macro you made.

    Second of all, thank you for the macro. It is almost complete.

    When I run it, I get the following error: Compile error: Method or data member not found.
    It highlights the ".Close" line of code.

    Is there something wrong that I did?

  9. #9
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Macro acts funny when more than 30 records are present

    Hello JPWRana,

    Comment the .Close line in the code like this ...
    Please Login or Register  to view this content.
    There is a single quote in front of the .Close which tells VBA what folows is a comment.

  10. #10
    Forum Contributor
    Join Date
    10-23-2004
    Location
    Los Angeles
    MS-Off Ver
    2010
    Posts
    253

    Re: Macro acts funny when more than 30 records are present

    Leith... that did it!

    Your macro fixed the problem of missing the middle rows of data, but added new issue.

    The NEW CSV GPS File is a copy of my GPS AUTOMATION Tool File that I originally uploaded.

    The one I currently need is under a new excel spreadsheet that's unnamed at Book1.


    The actual CSV GPS File that I need should have only 1 tab, and that is CSV GPS File.

    I hope i'm not confusing you.
    Last edited by JPWRana; 03-16-2017 at 05:02 PM.

  11. #11
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Macro acts funny when more than 30 records are present

    Hello JP,

    Hopefully I got this right. This version of the macro will use the workbook named "Book1" as the destination workbook. This workbook will have the data from the Template Workbook copied to the worksheet named "CSV GPS File" and saved to "C:\Documents and Settings\vargasr\Desktop\CSV GPS File.csv".

    Please Login or Register  to view this content.

  12. #12
    Forum Contributor
    Join Date
    10-23-2004
    Location
    Los Angeles
    MS-Off Ver
    2010
    Posts
    253

    Re: Macro acts funny when more than 30 records are present

    I ran the new macro, and I get the following error:

    Run-time error '9':
    Subscript out of range.

    The row

    Set DstWks = Workbooks("Book1").Worksheets("CSV GPS File")

    gets highlighted.

  13. #13
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Macro acts funny when more than 30 records are present

    Hell JP,

    The error indicates either the workbook named "Book1" does not exist or there is no worksheet named "CSV GPS File" in "Book1".

  14. #14
    Forum Contributor
    Join Date
    10-23-2004
    Location
    Los Angeles
    MS-Off Ver
    2010
    Posts
    253

    Re: Macro acts funny when more than 30 records are present

    When I run the macro (yours or mine), the only open file is GPS Automation.

    When I run your latest macro, do I need to have a 2nd file open already saved called Book 1 with a tab called CSV GPS File?

  15. #15
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Macro acts funny when more than 30 records are present

    Hello JP,

    I rewrote the macro based on what you said in post #10. So, yes is the answer to "When I run your latest macro, do I need to have a 2nd file open already saved called Book 1 with a tab called CSV GPS File?"

    I can alter the macro to open a new workbook and add the sheet, if that is what you really need.

  16. #16
    Forum Contributor
    Join Date
    10-23-2004
    Location
    Los Angeles
    MS-Off Ver
    2010
    Posts
    253

    Re: Macro acts funny when more than 30 records are present

    Yes please Leith. When i run my original macro... I have the macro make a new CSV file for me with 1 tab in it. The new tab doesn't necessarily have to be called CSV GPS File. I just thought it was convenient because my GPS AUTOMATION file has a tab in it called CSV GPS File that the MY MACRO would just copy over to A NEW CSV File.

  17. #17
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Macro acts funny when more than 30 records are present

    Hello JP,

    Third times is the charm. This creates a new CSV workbook and copies the contents of the Template, slightly modified, to the new workbook which is a single worksheet.

    Please Login or Register  to view this content.

  18. #18
    Forum Contributor
    Join Date
    10-23-2004
    Location
    Los Angeles
    MS-Off Ver
    2010
    Posts
    253

    Re: Macro acts funny when more than 30 records are present

    Leith, I get the original errors from Post #1. The middle part of the Name Column (Column B) appears blank. Sorry for the delayed response. Work caught up to me.

  19. #19
    Forum Contributor
    Join Date
    10-23-2004
    Location
    Los Angeles
    MS-Off Ver
    2010
    Posts
    253

    Re: Macro acts funny when more than 30 records are present

    Well Leith, thanks though anyways for your time and effort. I appreciate it. :-)

+ 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. [SOLVED] Macro acts differently when ran directly or through a command button
    By Caturne3 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-08-2015, 09:28 AM
  2. [SOLVED] VBA code to copy a part of cell value and assign the same to the records present below
    By kevivu in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-04-2015, 12:23 PM
  3. Add records manually entered on another sheet if not present on that one.
    By Nitefox in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 0
    Last Post: 09-20-2013, 02:59 PM
  4. Replies: 1
    Last Post: 03-04-2013, 09:22 AM
  5. [SOLVED] Macro acts on user selected worksheet
    By Ken Paxton in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-08-2012, 06:47 PM
  6. Excel Macro Acts Differently on Different Computers, even with same version
    By dbaft in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-24-2011, 07:58 AM
  7. can I clean old excel data format with macro on funny spread sheet
    By Todd F. in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-22-2005, 05:05 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