+ Reply to Thread
Results 1 to 1 of 1

Dynamic Formatting

  1. #1
    Registered User
    Join Date
    04-15-2009
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2003
    Posts
    1

    Dynamic Formatting

    Hi all,

    I am relatively new to programming macros in Excel, but have found VBA relatively straightforward so far.

    My problem is this:

    I have five columns that have already been sorted (This is for a psychology experiment): Subject #, run #, button press (1 or 2), condition, and onset time (in seconds).

    In the column just to the right of these, I am using the following formula to format them:


    5 1 1 Directions 0
    5 1 1 Directions 180.811
    5 1 1 Directions 241.971

    Please Login or Register  to view this content.


    Which makes it look something like this, for example:

    s5_r1_pp1_Directions=[0 180.811 241.971]



    My question is, if there is another block right after that

    5 1 1 Directions 0
    5 1 1 Directions 180.811
    5 1 1 Directions 241.971
    5 1 1 Negative 6.089 <----starting here
    5 1 1 Negative 24.858
    5 1 1 Negative 34.1
    5 1 1 Negative 45.912
    5 1 1 Negative 186.85
    5 1 1 Negative 192.706
    5 1 1 Negative 200.213
    5 1 1 Negative 293.488

    How would I write the code so that it recognizes when the condition column (column 4) changes from "Directions" to "Negative", and formats it accordingly? I'm assuming I would have to use R1C1 notation, and some kind of counter so that it knows how many onsets times are in each condition. That way, it would concatenate the correct number of cells. Note that I would want only one formatted output string for each condition block; for example, one for Directions, and one for Negative.

    Desired output:

    5 1 1 Directions 0 s5_r1_pp1_Directions=[0 180.811 241.971]
    5 1 1 Directions 180.811
    5 1 1 Directions 241.971
    5 1 1 Negative 6.089 s5_r1_pp1_Negative=[6.089 24.858 34.1 45.912 186.85 192.706 200.213 293.488]
    5 1 1 Negative 24.858
    5 1 1 Negative 34.1
    5 1 1 Negative 45.912
    5 1 1 Negative 186.85
    5 1 1 Negative 192.706
    5 1 1 Negative 200.213
    5 1 1 Negative 293.488


    Any help is greatly appreciated. Thanks!

    -Andrew
    Last edited by VBA Noob; 04-15-2009 at 01:53 PM. Reason: Added code tags as per forum rules

+ 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