+ Reply to Thread
Results 1 to 3 of 3

VBA Sum Records Which Match Monthly Column Heading

  1. #1
    Forum Contributor
    Join Date
    05-26-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2013
    Posts
    682

    VBA Sum Records Which Match Monthly Column Heading

    Hi, I wonder whether someone may be able to help me please.

    With some help along the way and with some adaptation by myself, I’ve put together the following code

    Please Login or Register  to view this content.
    The code initially selects column B on the "All Data" sheet for unique values. The aim of this is to see whether the cell value matches a sheet name (already created), contained within the workbook. Then performs the following:

    • When a match is found, the code then moves onto the first 'Select Case' statement and works through looking for the various criteria in the 'Case' sub routines i.e. Case nUseAllDIR, Case nUseAllEH, Case nUseAllIND, Case nUseAllOVH and Case nUseAllPRO.

      NB. For information, a(i, 1) = ws.Name is column B, (a(i, 6), "Consultancy & Innovation") = 0 is column G and (a(i, 8), "TM - DIR") > 0 is column I all on the "All Data" sheet.
    • When these criteria are met the code then moves onto the following piece of code.

      Please Login or Register  to view this content.

      Where it looks to see if firstly there is a value in column M on the [B]"All Data"[/B ]sheet, and where it does it then copies the associated value in column Q on the "All Data" sheet.

    • Finally when these values are copied, the code moves onto the second 'Select Case' statement and pastes the value into the relevant cell.

    This code works, but it is painfully slow, to the point it takes over an hour to extract, and I admit, that despite trying for over a week, I've not been able to make this any better.

    I just wondered whether someone may be able to look at this please and offers some guidance on how to amend this.

    I appreciate that this is a fairly lengthy and technical post, my apologies, but I thought it better to be as accurate with the process as possible. To help I've included a file here: https://www.dropbox.com/s/dc3b3dwr4n...0Home.xls?dl=0


    To launch the macro which extracts the data to the individual sheets please click the button, but as I say this process takes a long time.

    I did try to attach the file to the post, but it was over the file size limit.

    Many thanks and kind regards

    Chris

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: VBA Sum Records Which Match Monthly Column Heading

    You should have posted a spreadsheet.

    Try these:-

    1. Run my Optimise subroutine to speed up your macro:-


    Please Login or Register  to view this content.

    2. Replace
    Please Login or Register  to view this content.
    with
    Please Login or Register  to view this content.
    3. What is the point of:-

    Please Login or Register  to view this content.
    Replace with:
    Please Login or Register  to view this content.

    4. What is the point of:-

    Please Login or Register  to view this content.
    Replace with:-

    If a(i, 1) = ws.Name And InStr(a(i, 6), "Consultancy & Innovation") = 0 And InStr(a(i, 8), "TM - OVH") > 0 Then bColumnCIsConsultancyAndRequirements = True

  3. #3
    Forum Contributor
    Join Date
    05-26-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2013
    Posts
    682

    Re: VBA Sum Records Which Match Monthly Column Heading

    Hi @mehmetcik, thank you very much for taking the time to come back to me with this, it's greatly appreciated.

    I made the amendments to my code as you kindly suggested, and it ran without error, but the problem is, is that this has made no difference to the time it takes to extract the information.

    Many thanks and kind regards

    Chris
    Last edited by hobbiton73; 09-01-2014 at 04:37 AM.

+ 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] VBA Sum Figure Which Match Both Column & Row Heading
    By hobbiton73 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-19-2014, 12:47 PM
  2. [SOLVED] VBA Count Records Which Match Column Heading
    By hobbiton73 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-20-2014, 05:24 AM
  3. Replies: 9
    Last Post: 10-22-2012, 02:03 PM
  4. Replies: 0
    Last Post: 05-17-2012, 12:59 PM
  5. Excel 2007-Multiple Column Heading Relocation for multiple records
    By ToddPOH in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 06-27-2011, 04:48 PM

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