+ Reply to Thread
Results 1 to 3 of 3

Macro adjustment needed: merged cells & countif match

  1. #1
    Registered User
    Join Date
    06-23-2014
    Location
    Iqaluit, Nunavut
    MS-Off Ver
    2010
    Posts
    2

    Macro adjustment needed: merged cells & countif match

    Hello all. A slight macro adjustment should be possible I think to solve this pretty simple problem. Here is my data (there are four columns and ~5000 rows):

    ________________________________________________
    Name.........Start Time.........End Time..........Duration
    ________________________________________________
    ..................8AM..................9AM..................1 hour
    .................930 AM..............11AM..................1.5 hours
    Lightbulb.....11AM..................12PM................1 hour
    .................12PM....................1PM.................1 hour
    ..................1PM....................2PM..................1 hour
    ________________________________________________
    ..................8AM..................9AM..................1 hour
    Fan.............9AM..................12PM.................3 hours
    ..................5PM..................530PM...............0.5 hours
    _________________________________________________
    etc. etc. etc.


    The macro below is able to sum a variable number of the "duration" rows depending on when the "name" merged cell (i.e. "lightbulb") stops and ends. This issue is already solved; we are moving onto another problem now that I believe can use the same base code?

    Please Login or Register  to view this content.
    The syntax for that question is as follows:

    =SUMMERGE(Target Range, Offset Column, Lookup Value)

    Target range is the column of cells you wish to look within for the lookup value. This will be the column that has the merged cells. -----> "Name" column
    Offset Column is a number representing the column to Sum. A positive number means that many columns to the right of the Target column, while a negative number represents that many columns to the left. ------> "3" in this case
    Lookup Value is the value you are looking for. ------> i.e. "Lightbulb" or "Fan"
    Notice how the end time of a certain row can sometimes be identical to the start time of the following row. Now I would like to count the number of instances that there are identical end&start times for each set of "name" cells (which are often - but sometimes not - merged cells). There would be 3 occurrences for "lightbulb" (11AM, 12PM & 1PM) and 1 for "fan" (9AM) in this example.

    I cannot unmerge the "name" cell to make this easier unfortunately. As you can see, the number of rows each set of "names" contains varies - sometimes it is 5 rows, sometimes it is 3 rows, sometimes it isn't even a merged cell and is only 1 row. Can you help me out? I have almost zero macro experience. The macro above is working perfectly for the summing task and and might make this counting task an easy question to answer?

    Thanks!
    Last edited by djvent; 06-23-2014 at 04:02 PM. Reason: Title Change

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,860

    Re: Slight Macro Adjustment?

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution.

    Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.

    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    06-23-2014
    Location
    Iqaluit, Nunavut
    MS-Off Ver
    2010
    Posts
    2

    Re: Macro adjustment needed: merged cells & countif match

    Title has been changed...my apologies.

+ 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. [SOLVED] 5 year annual turnover calculated from start date - needs slight adjustment
    By aaaaaaiden in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-03-2013, 07:30 AM
  2. [SOLVED] Slight Editing of Existing Macro Required
    By aleem5 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-20-2013, 11:36 PM
  3. [SOLVED] Slight code adjustment please
    By dannac in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-06-2012, 04:36 PM
  4. to combine two cell into one with slight adjustment
    By mingali in forum Excel General
    Replies: 4
    Last Post: 07-15-2010, 04:00 AM
  5. Slight adjustment to this formula
    By RunHard in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-11-2009, 04:32 PM

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