+ Reply to Thread
Results 1 to 25 of 25

In & Out Array processing changes data

  1. #1
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    In & Out Array processing changes data

    Hello All,

    I've come across a perplexing situation wherein when I pull all the data into an array, operate on elements within that array and then replace the array in its original spot some of the fields (fields not operated upon) change themselves into date format. Have any of you ever encountered this phenomenon?
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  2. #2
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: In & Out Array processing changes data

    Yes, I have had that happen and I could not figure out why. In the end I worked out that b/c the data was from an external file it needed to be cleaned of any of the formatting.
    Be fore warned, I regularly post drunk. So don't take offence (too much) to what I say.
    I am the real 'Napster'
    The Grid. A digital frontier. I tried to picture clusters of information as they moved through the computer. What did they look like? Ships? motorcycles? Were the circuits like freeways? I kept dreaming of a world I thought I'd never see. And then, one day...

    If you receive help please give thanks. Click the * in the bottom left hand corner.

    snb's VBA Help Files

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: In & Out Array processing changes data

    Excel tries to be helpful. It would be informative if you provided some examples of the BEFORE value and the AFTER value. I'm going to guess the BEFORE value does have the semblance of date elements, enough that as the data is written into the cells at the end Excel recognizes it as a date format and converts it.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: In & Out Array processing changes data

    @Dave - thanks Dave, but what do you do with the format - I never see the external file, I get that from the client.

    @Jerry - I'll give an example next time I have my 2010 up (it's only on my laptop) - but it doesn't look like date material, although there is a dash.

  5. #5
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: In & Out Array processing changes data

    Hi All,

    This program:

    Please Login or Register  to view this content.
    The original field data is 03-1972 The rendered field data Mar-72 showing from 3/1/1972 in formula bar.

    BTW - both ww and w1 have in excess of 100k rows and the program took 49 mins to run - any suggestions?

  6. #6
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: In & Out Array processing changes data

    my suggestion: post a sample workbook



  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: In & Out Array processing changes data

    There you go... 03-1972 is absolutely a date string that Excel could and does "spot" converting it to March 1, 1972.

    Suggestion:
    1) make triple sure the column holding these values is formatted as TEXT before writing into the cells again
    2) Skip this column with inserting your array of data
    3) Copy the original values safely to another part of the sheet and back again after the array writes back.

  8. #8
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: In & Out Array processing changes data

    @snb - I can't post the workbook as it belongs to the client.

    @Jerry - I used option three - I considered option two - but I've had bad luck with option one in the past - thanks!

  9. #9
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: In & Out Array processing changes data

    @xladept

    I asked for a sample workbook.

  10. #10
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: In & Out Array processing changes data

    @snb -

    The thing is that the problem is in its size, the one sheet is 113K X 3 and the other is 118K X 72.

    Did you notice some inefficiency in my code? The records cannot be sorted (unless you propose some device to reorder them after processing).

  11. #11
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: In & Out Array processing changes data

    Size is never a problem in a workbook that only contains a representative sample of the data you are working with.

    You make your code much more readable if you omit the : and put each line of code it's own codeline.
    Using 'activate' or 'select' is inherently inefficient.
    Looping to check whether a sheet exists falls in the same category.
    Using several 'finds' to determine the builtin 'usedrange' isn't elegant either.

  12. #12
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: In & Out Array processing changes data

    @snb - Thanks for the critique - I believe that the readability issue is a matter of taste - I like those "finds" to determine my parameters - I wanted the Master showing, which it wouldn't if I had to add the auxiliary sheet - how would you suggest that I find the auxiliary sheet?? - But, I was hoping for some suggestions that would make the code run faster

  13. #13
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: In & Out Array processing changes data

    Post a sample workbook and I can show you a much faster approach.

  14. #14
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: In & Out Array processing changes data

    Hi snb,

    I can't resist your offer:

    https://www.dropbox.com/s/aa64d4k1i1...pleMaster.xlsx

    Sorry about this but the uploader didn't work today
    Last edited by xladept; 11-26-2013 at 01:09 PM.

  15. #15
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: In & Out Array processing changes data

    Is sheet 2 representing the desired result ?

    Can you describe the desired resutl ?

  16. #16
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: In & Out Array processing changes data

    Hi snb,

    The sample sheet1 is the master ww in my program, sheet2 (w1) is the data to be inserted onto sheet1 and sheet 3 (w2) is the repository for the master items that didn't match. Basically, the program adds the sheet 2 data (A-C) to the sheet 1 data (B-D) then at the bottom appends the sheet 2 data that found no match and, finally, the master records that didn't match are collected on sheet 3.

  17. #17
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: In & Out Array processing changes data

    To make a start:

    Please Login or Register  to view this content.

  18. #18
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: In & Out Array processing changes data

    Hi snb,

    This qualifies for me as the caveat in your signature - it's a glaring hole in my development! Can you steer me in the direction that will allow me, in time, to understand this kind of code??

    This code is really a lot faster than my code!!

    And, thanks for this!
    Last edited by xladept; 11-27-2013 at 03:04 PM.

  19. #19
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: In & Out Array processing changes data

    I feared your 'next' question.

    Especially for you I wrote this for an answer:

    http://www.snb-vba.eu/VBA_Dictionary_en.html

  20. #20
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: In & Out Array processing changes data

    Thanks snb - I've now got reading material for a good while to come!

    The dictionary must be populated sequentially it seems, so I'll have to adjust my random mind

  21. #21
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: In & Out Array processing changes data

    Yes, your coding was clearly demonstrating it's origin ..

  22. #22
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: In & Out Array processing changes data

    I'll start with "getting my nose out of joint"

    The ability to write that blazing fast code must exacerbate hubris.

    How would you write the rest of the routine??
    Last edited by xladept; 11-28-2013 at 02:50 AM.

  23. #23
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: In & Out Array processing changes data

    I already gave you a clue: if an item in sn exists in sp, sn(j,1) will be 'cleaned'; so all items that have not been found contain some value in sn(j,1)

  24. #24
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: In & Out Array processing changes data

    It takes time for an "old dog" when there are new tricks - I'll be pondering

    Duhhhhhhhhhhhhhhhhh
    Last edited by xladept; 11-28-2013 at 10:08 PM.

  25. #25
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: In & Out Array processing changes data

    This is how I made it work:

    Please Login or Register  to view this content.
    Last edited by xladept; 12-03-2013 at 09:24 PM. Reason: Solution, of a sort, arrived at - final update:)

+ 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. Processing dates into an array and then outof array
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-16-2013, 12:45 PM
  2. Change ARRAY formula to minimize excel processing
    By swampedindata in forum Tips and Tutorials
    Replies: 4
    Last Post: 02-17-2012, 10:54 AM
  3. Loop Array Iteration and Processing
    By Bigced_21 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-01-2010, 11:16 AM
  4. Processing Data
    By kroz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-20-2009, 02:32 AM
  5. cant select array of csv files for processing
    By lawrencef in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-08-2009, 07:41 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