I am using excel to keep track of certain data in the following form:
Date Name ID
1/01, A, 1
1/01, B, 2
1/02, C, 3
1/02, D, 4
1/03, E, 5
I want to set up a schedule based on this data, but in order to do that, I need to find and output the ranges for samples that have the same date.
Example:
1/01: IDs 1-2
1/02: IDs 3-4
1/03: ID 5
How would I go about doing this? I tried using lookup, but it gets majorly confused when dealing with duplicate data (and it only finds one instance at any rate).
Clarification:
Basically, I want to find all the values that have the date 1/02, and get the lowest and highest IDs that have these dates.
Below is the code to meet your requirement as I understand it.
I assume column “A” contains Excel dates with a display format of mm/dd.
To the moderately experienced VBA programmer this is a trivial task so I am assuming you are not a VBA programmer or are very inexperienced. I have avoided the more advanced features. However, I have used formatting (dates displayed as mm/dd, bold, alignment), which you did not ask for, to show you how it is done. I have not told you how to access the VB Editor or how to create a module. If you do not know, please ask. I had someone put some code in the wrong place a while back and it was a difficult to explain how to get it out.
I had said what statements or blocks of statements are doing but have not provided full explanations. The idea is to tell you enough to allow you to make minor changes to the code and to allow you look features up in Help if you want to go further. I do recommend you go further. Once you are over the first hill, most of VBA is flat countryside. However, there are some serious mountains if you want to go even further.
I have assumed all the Ids are integers. If they are strings, you must change the type of
IdCrnt,SummaryIdFirstandSummaryIdLastfromIntegertoString. If they are values like: “1”, “2”, “2a”, “2b”, “3”, “4”, etc you will have a problem because “10” is less than “1a”.I have placed the summary in unused columns within the source worksheet “Sheet1”. Change the names of the worksheets in the With statements as required.
Best of luck.