+ Reply to Thread
Results 1 to 19 of 19

vba to calculate record summary

  1. #1
    Forum Contributor
    Join Date
    11-17-2015
    Location
    India
    MS-Off Ver
    2013
    Posts
    365

    vba to calculate record summary

    Hi,
    I have a data in specific Format as per Sheet “Data”. In column H there is relation against all records in column F there is age bracket against all records. In sheet “Template” I have template in which data to be summarised as per age band. Example data given in Sheet “Data As per Template”.


    Now I need macro for below task.

    1) All records in data to be checked as per age in band (in column F) and as per Sum insured (in column K) and put the count in respective column in template.
    2) In Template sheet there is Column “Total Self Count” (column M). In column M, only check the count of self in sheet “Data” and put the count of only self in Column M as per sum inured (in column K of sheet “Data”)

    Please refer sheet “Data As per Template” for example.
    Attached Files Attached Files

  2. #2
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,288

    Re: vba to calculate record summary

    Hi saravanan1981

    Wanna give this a go....
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  3. #3
    Valued Forum Contributor
    Join Date
    10-13-2010
    Location
    Sunderland, England
    MS-Off Ver
    Excel 2007 (Home) / 2003 (Work)
    Posts
    740

    Re: vba to calculate record summary

    Hi

    Is there a reason this needs to be a macro solution? A formula solution is fairly easy to achieve:

    Columns B:J:
    =COUNTIFS(Data!$K:$K,'Data As per Template'!$A2,Data!$E:$E,"<="&INT(RIGHT('Data As per Template'!B$1,2)),Data!$E:$E,">"&INT(LEFT('Data As per Template'!B$1,FIND("-",B$1)-1)))

    Col K:
    =COUNTIFS(Data!$K:$K,'Data As per Template'!$A2,Data!$E:$E,">"&INT(RIGHT('Data As per Template'!K$1,2)))

    Col M:
    =COUNTIFS(Data!$K:$K,'Data As per Template'!$A2,Data!$H:$H,"Self")

  4. #4
    Forum Contributor
    Join Date
    11-17-2015
    Location
    India
    MS-Off Ver
    2013
    Posts
    365

    Re: vba to calculate record summary

    Dear Sintek,
    The in template sheet only first row (Age Band) is constant row.

    The number in First column (SI) is not constant. The number will change as per the data. Accordingly SI rows to be adjusted.

    For example I have added another SI slab of Rs.3000000. Hence rows will change accordingly. Please refer attachment.
    Attached Files Attached Files

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,588

    Re: vba to calculate record summary

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    11-17-2015
    Location
    India
    MS-Off Ver
    2013
    Posts
    365

    Re: vba to calculate record summary

    Dear Jindo,
    Thank you very much for your reply.
    I wants to create number of rows equal to number of Sum insured in template automatically.

    e.g. If SI is only 50000, 75000, 100000, 150000 then create only 4 rows.

    IF SI as below, then create 12 rows, because there 12 SI below. which is not happening in attachment.

    50000
    75000
    100000
    150000
    250000
    275000
    350000
    400000
    600000
    2500000
    3000000
    6000000

    for e.g in attachment I ave crated one more SI of Rs.3500000 and that particular row is not created.

    In short SI will be variable from data to data
    Attached Files Attached Files

  7. #7
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,288

    Re: vba to calculate record summary

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by sintek; 08-08-2017 at 06:08 AM.

  8. #8
    Forum Contributor
    Join Date
    11-17-2015
    Location
    India
    MS-Off Ver
    2013
    Posts
    365

    Re: vba to calculate record summary

    it is working correct.

    But creates two total row. Please refer attachment.

    Also Borders are not coming till last row and last column.
    Attached Files Attached Files

  9. #9
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,288

    Re: vba to calculate record summary

    See attached...
    Attached Files Attached Files

  10. #10
    Forum Contributor
    Join Date
    11-17-2015
    Location
    India
    MS-Off Ver
    2013
    Posts
    365

    Re: vba to calculate record summary

    perfect.... perfect..... perfect.... thanks a ton.

  11. #11
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,288

    Re: vba to calculate record summary

    This incorporates all shading and borders...
    Thanks for rep +

    Please Login or Register  to view this content.

  12. #12
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,588

    Re: vba to calculate record summary

    Please Login or Register  to view this content.

  13. #13
    Forum Contributor
    Join Date
    11-17-2015
    Location
    India
    MS-Off Ver
    2013
    Posts
    365

    Re: vba to calculate record summary

    Dear Sintek,
    One Small Help again. I have changed the template little bit.

    Change is only in age slab. Can you please change the code accordingly.

    Please refer attachment.

    also can you please guide me which line of code to be changed if I want to manipulate in age band.
    Suppose if I want to change the age band as per my requirement.
    Attached Files Attached Files
    Last edited by saravanan1981; 08-08-2017 at 08:11 AM.

  14. #14
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,288

    Re: vba to calculate record summary

    Try this...
    With the change in age band...What do you mean...Adding more/less columns?
    If so, the red pieces need to be edited.
    Please Login or Register  to view this content.
    Last edited by sintek; 08-08-2017 at 09:22 AM.

  15. #15
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,588

    Re: vba to calculate record summary

    .......................
    Attached Files Attached Files

  16. #16
    Forum Contributor
    Join Date
    11-17-2015
    Location
    India
    MS-Off Ver
    2013
    Posts
    365

    Re: vba to calculate record summary

    Dear Jindon,
    Can you please provide me the code as it is protected. I wants to copy the same in some other sheet

  17. #17
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,288

    Re: vba to calculate record summary

    This is greek to me....I just so wish Master Jindon could teach or perhaps refer to explanations of his code...

    Please Login or Register  to view this content.
    Last edited by sintek; 08-09-2017 at 07:11 AM.

  18. #18
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,588

    Re: vba to calculate record summary

    Some idio* seem to know the way to crack the password.
    Please Login or Register  to view this content.

  19. #19
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,288

    Re: vba to calculate record summary

    @ jindon

    Please be so kind and point me to a link so that I may understand this amazing code....Pretty please.

+ 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] Creating a summary table from daily attendance record
    By saifsawafi in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-21-2017, 03:13 AM
  2. calculate percentage of certain entries for specified record
    By kramart in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-22-2013, 02:57 AM
  3. Replies: 4
    Last Post: 12-17-2012, 10:14 AM
  4. Replies: 1
    Last Post: 11-16-2012, 09:25 AM
  5. How to calculate the duplicate record amount
    By gingank in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-20-2012, 06:38 AM
  6. [VBA]- Creating a semi - automatic summary/record page.
    By RandomInteger in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-12-2012, 02:17 AM
  7. record data in a summary
    By brissy in forum Excel General
    Replies: 0
    Last Post: 06-20-2007, 06:18 AM

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