+ Reply to Thread
Results 1 to 9 of 9

Matching Date

  1. #1
    Registered User
    Join Date
    03-16-2015
    Location
    Bangkok
    MS-Off Ver
    2007
    Posts
    28

    Matching Date

    Hi, could any of you beautiful people out there please help write a VBA Macro for me. I’m very new to VBA programming and need your help.

    I’ve a big set of data, with columns containing date and price of different products.

    First, I’d like to
    - Highlight the entire column with dark grey color if cells in row 4 contains the word Timestamp
    - Highlight the entire column with light orange color if cells in row 4 contains the word Trade Close

    Second
    - Match the date so that all columns with a specific date is in the same row, that is there will be only one date per row of the entire data set, move the date so that it matches each other and also move its corresponding prices too.

    Please see attached excel file.

    I thank you in advance of your help. Your kindness is much appreciated.

    Vku
    Attached Files Attached Files

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,933

    Re: Matching Date

    For the coloring part, you dont need VBA, try this...

    1. highlight the range you want to apply the conditional formatting to (B3:LI122 in your sample)
    2. on the home tab, styles, select CF
    3. select new rule, select use formula
    4. enter =B$4="TimeStamp" Format fill Grey

    For the sorting, you will need VBA - not my strong side
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: Matching Date

    I agree with Ford that for the coloring, conditional formatting is the way to go.

    For the sorting:
    What do you want to happen when a column doesnt have a certain date.
    For example, in your file, from column J, the date 2/4/2011 is missing (among others).

  4. #4
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Matching Date

    I'm not so sure I agree. That is a lot of cells you are concerned with coloring and CF is considered volatile.

    Decision Models



    "Conditional Formats are volatile.

    Because conditional formats need to be evaluated at each calculation any formulae used in a conditional format is effectively volatile. Actually conditional formats seem to be super-volatile: they are evaluated each time the cell that contains them is repainted on the screen, even in Manual calculation mode, although VBA functions used in conditional formats will not trigger breakpoints when executed by the repaint."
    Click the * Add Reputation button in the lower left hand corner of this post to say thanks.

    Don't forget to mark this thread SOLVED by going to the "Thread Tools" drop down list above your first post and choosing solved.

  5. #5
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Matching Date

    Here's a macro you can run as needed to color the columns.
    To install it you can click Alt + F11 and in the window that comes up choose insert from the drop down menus and choose module.
    Then paste the code into the window. Save the workbook as a .xlsm style file and then run the macro.

    Please Login or Register  to view this content.

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,933

    Re: Matching Date

    skywriter, I agree that excessive use of CD can start to slow your file down. If the data range is far larger than the sample, then VBA would be the go. However, you have included both into 1 macro, so that would be a better option

  7. #7
    Registered User
    Join Date
    03-16-2015
    Location
    Bangkok
    MS-Off Ver
    2007
    Posts
    28

    Re: Matching Date

    Thanks everyone for the post, the VBA macro to highlight the cells work perfectly.

    If anyone could also help me out with the sorting and matching the dates I would highly appreciated it.
    Please see the attached file in the post.

    Thanks in advance.

    Vku

  8. #8
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Matching Date

    Quote Originally Posted by FDibbins View Post
    skywriter, I agree that excessive use of CD can start to slow your file down. If the data range is far larger than the sample, then VBA would be the go. However, you have included both into 1 macro, so that would be a better option
    Sorry I don't understand the reply.
    I have included both "what" into 1 macro?

  9. #9
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,933

    Re: Matching Date

    Quote Originally Posted by skywriter View Post
    Sorry I don't understand the reply.
    I have included both "what" into 1 macro?
    Sorry, I thought your macro did the CF and the sorting for them

+ 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. Sum ifs - Based on Matching Date (exact date not range)
    By alyssakhan in forum Excel General
    Replies: 11
    Last Post: 06-03-2014, 03:35 PM
  2. Add date criteria matching order date and sales date
    By Luther.King in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-25-2014, 10:09 AM
  3. [SOLVED] Fill End Date with Start date of the next Matching Entry
    By Whraith in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-20-2013, 12:06 AM
  4. [SOLVED] Finance Question- matching sales value date with that of amount received date
    By paradise2sr in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 09-20-2013, 05:52 AM
  5. Indexing and matching data from date range and matching
    By Rickomicko in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-19-2013, 11:46 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