+ Reply to Thread
Results 1 to 9 of 9

Processing data

  1. #1
    Registered User
    Join Date
    02-25-2010
    Location
    Reading, England
    MS-Off Ver
    Excel 2007
    Posts
    7

    Processing data

    Hey all,

    I am trying, and failing, to write a macro which can process a number of results I have in my spreadsheet. I will upload an example book with some current musing in the vba editor, with a recording on what I need to do naturally (missing some complex steps).
    www.megaupload.com/?d=FF0R8H1L

    What I have is a set of four sensor readings with sample time on multiple sheets inside my workbook. An example of what I want doing is copy the sample time, open a new file and paste it in and take the first data column and paste it into the new file. Then multiply it by 10^-3 then save it as a csv with a filename in the form "SDrink<sheet number><if the column heading has upper or lower, I or O respectively><sensor S or C> thats gotta be done for every data column then every sheet.
    So I end up with a CSV with every sensor separately named according to which dataset and which sensor it is.

    Unfortunately I don't know VB very well or the syntax, as my experimentation show.
    Thanks for reading my rambling, Its quite an ask.
    Wip
    Last edited by Wipster; 02-25-2010 at 12:43 PM.

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Processing data

    File unavailable. Try uploading here, easier all round.

  3. #3
    Registered User
    Join Date
    02-25-2010
    Location
    Reading, England
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Processing data

    Ahh ok, didn't realise that I could attach on here, once that file becomes available I shall pop it into this message.
    Thanks.
    Attached Files Attached Files
    Last edited by Wipster; 02-25-2010 at 01:55 PM.

  4. #4
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Processing data

    Ok getting there, but can you add to your file an illustration of your expected output based on the raw data. I'm not entirely sure I follow.

  5. #5
    Registered User
    Join Date
    02-25-2010
    Location
    Reading, England
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Processing data

    Unfortunatly my example csv's are on my work computer and I dont have office at home. The csv's should only contain the time and one of the 4 sensors (multiplied by 10^-3).
    <Time> <sensor reading>
    0 -0.345
    2 -0.347
    4 -0.361
    6 -0.368

    In there csv there should be no column names, my simulation engine doesn't like them heh.
    The naming convention could be something like, for sheet 1 and the sensor tagged "Lower S corrected" "SDrink1OS", for sheet 2 and same sensor "SDrink2OS".
    For sheet 3 and sensor tagged "Upper C Corrected", "SDrink3IC". This is just so I can identify from the filename the batch its come from and the sensor. Either that or its Simply "UpperS", "LowerC" etc in a new folder SDrink/<sheet number>/ might be better for organising and understanding. <- That is probably a better way of doing if you havn't already.
    Last edited by Wipster; 02-25-2010 at 03:15 PM.

  6. #6
    Registered User
    Join Date
    02-25-2010
    Location
    Reading, England
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Processing data

    I have worked out copying the sensors and time to separate sheets in the original book, not managed switching between books, Can I say multiply this by 10^-3 as its coming out of copy? It would be so much cleaner if I could just .value it but does that work cross book?

    Edit:- I see I can use SpecialPastes operation Multiply but I need to put what I want to multiply it with in the cells how can I tell it to fill the amount of cells which are in the first column with "10^-3" in the second? I tried with a range but it made a rectangle of "10^-3".

    Here is where I am at
    Please Login or Register  to view this content.
    Last edited by Wipster; 02-26-2010 at 10:54 AM.

  7. #7
    Registered User
    Join Date
    02-25-2010
    Location
    Reading, England
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Processing data

    Hi all,

    Cheres for some great resources here to look through, I think I have picked up the language roughly. I have a program which works but is probably using bad practice would it be ok for someone to have a look over and suggest other methods or ways to make it less hacks. Dont want to get into bad habbits.

    Please Login or Register  to view this content.

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Processing data

    I'd use objects rather than strings, more like this (but completely uuntested).
    Please Login or Register  to view this content.
    BTW, in VBA, in a declaration like this,
    Please Login or Register  to view this content.
    ...alll but k are declared as variants. You can do this:
    Please Login or Register  to view this content.
    ... but my preference is to declare one variable per line.
    Entia non sunt multiplicanda sine necessitate

  9. #9
    Registered User
    Join Date
    02-25-2010
    Location
    Reading, England
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Processing data

    Thanks for the tips there, that code does look allot cleaner then mine and it worked straight off the batt too, kudos :D

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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