Page 1 of 2 12 LastLast
Results 1 to 12 of 23

Thread: SUM cell based on their interior color(Have fun with excel)

  1. #1
    syar is offline Advance Member
    Last Online
    2nd May 2024 @ 09:24 AM
    Join Date
    31 Jul 2009
    Location
    Nowshera(KP)
    Age
    47
    Gender
    Male
    Posts
    886
    Threads
    10
    Credits
    563
    Thanked
    340

    Default SUM cell based on their interior color(Have fun with excel)



    Suppose agar aap k pass aik excel ki file ha Jis m 1000 memebers ki detail ha aur aap ne un ki amount ya salary etc k cell ko color deya huwa ha Aur aap chchte ho k sirf un cell ko sum kiya jae jis k color yellow ya green etc ho.
    It is possible in Microsoft Excel. Leekan is k leye aap ko VBA (Macro) istimal karna ho gi. Jis k leye follow these steps

    1. Press Alt+F11
    2. Insert menu m ja kar module select karain aur open hone wale window m following code enter karain.

    -------------------------------------------------------------------------
    Function Sumbycolor(cellcolor As Range, sumrange As Range)
    Dim mycell As Range
    Dim icol As Integer
    Dim mytotal
    icol = cellcolor.Interior.ColorIndex 'get the target color
    For Each mycell In sumrange 'look at each cell in the designated range
    'if the cell color matches the target color
    If mycell.Interior.ColorIndex = icol Then
    'add the value in the cell to the total
    mytotal = WorksheetFunction.Sum(mycell) + mytotal
    End If
    Next mycell
    Sumbycolor = mytotal
    End Function
    -----------------------------------------------------------

    Now you can use this function like this.

    =sumbycolor(cellcolor,sumrange)

    where cellcolor -------The address of a cell with taget color( yani jis cell k color ko base bana chahte hain.

    sumrange------The range of cell to be summed. ( yani jis range ko aap jama karna chahte hain.

    =sumbycolor(a1,a1:a10)

    see the attached picture.

    Note Jis cell ko conditional format keya ho wo cell pa ye apply nahe hoga. Cell k background color he sum honge. Font agar color ho ga tu sum nahee honga.

    may be this will help
    regards
    Attached Images Attached Images  

  2. #2
    M-Qasim's Avatar
    M-Qasim is offline Advance Member+
    Last Online
    7th September 2022 @ 07:41 PM
    Join Date
    22 Mar 2009
    Gender
    Male
    Posts
    33,351
    Threads
    915
    Credits
    1,718
    Thanked
    3391

    Default


    Superb Work

    Nice Sharing .... Thanks for Sharing







  3. #3
    mani's Avatar
    mani is offline Senior Member+
    Last Online
    21st November 2009 @ 11:53 AM
    Join Date
    03 Jan 2006
    Location
    pakistan/rawalpindi
    Age
    35
    Posts
    99
    Threads
    0
    Credits
    0
    Thanked
    3

    Default

    nice

  4. #4
    friend4allage's Avatar
    friend4allage is offline Advance Member
    Last Online
    31st July 2023 @ 08:53 AM
    Join Date
    05 Apr 2009
    Age
    44
    Posts
    662
    Threads
    62
    Credits
    353
    Thanked
    21

    Default

    nice

  5. #5
    syar is offline Advance Member
    Last Online
    2nd May 2024 @ 09:24 AM
    Join Date
    31 Jul 2009
    Location
    Nowshera(KP)
    Age
    47
    Gender
    Male
    Posts
    886
    Threads
    10
    Credits
    563
    Thanked
    340

    Default



    Hosla afzaee k leye Aap sab a shukriya.

  6. #6
    Shehzad Iqbal's Avatar
    Shehzad Iqbal is offline Advance Member+
    Last Online
    26th November 2023 @ 06:28 PM
    Join Date
    16 Jan 2009
    Location
    Karachi
    Gender
    Male
    Posts
    28,463
    Threads
    2271
    Credits
    11,705
    Thanked
    5385

    Default

    wao
    super work yaar
    thanx for sharing

  7. #7
    jaadoogar is offline Member
    Last Online
    27th March 2010 @ 06:13 PM
    Join Date
    25 Oct 2008
    Location
    Jadu Nagri
    Age
    43
    Posts
    543
    Threads
    48
    Thanked
    30

    Default

    gr888 work dear

  8. #8
    saeed pk is offline Junior Member
    Last Online
    26th February 2018 @ 09:03 PM
    Join Date
    14 Nov 2009
    Posts
    21
    Threads
    2
    Credits
    0
    Thanked: 1

    Default

    well done

  9. #9
    Jaffary is offline Senior Member+
    Last Online
    23rd May 2021 @ 01:04 PM
    Join Date
    06 Mar 2009
    Age
    48
    Posts
    336
    Threads
    11
    Credits
    1,252
    Thanked
    4

    Default


  10. #10
    zulfi721's Avatar
    zulfi721 is offline Senior Member+
    Last Online
    4th May 2017 @ 03:41 PM
    Join Date
    05 Mar 2010
    Location
    On Planet earth
    Posts
    926
    Threads
    103
    Credits
    1,104
    Thanked
    66

    Default

    Good work,but bhai programing sy dur he lugta hy )sheet ka kya sy kya haal kr dy)sorry i m saying so because i m not familiar with programing.....any how aap ke sharing mazy ke hy...lets give it a try

  11. #11
    Muazzam Sameer is offline Senior Member+
    Last Online
    11th October 2015 @ 03:44 PM
    Join Date
    19 May 2010
    Age
    39
    Posts
    48
    Threads
    11
    Credits
    0
    Thanked
    2

    Default

    good yar

  12. #12
    Ganxtr's Avatar
    Ganxtr is offline Advance Member
    Last Online
    5th July 2019 @ 09:15 AM
    Join Date
    15 Nov 2009
    Location
    CRIME CITY
    Posts
    1,740
    Threads
    18
    Credits
    83
    Thanked
    100

    Default

    NYC....
    Your thread is very useful, thanks for sharing with us.

Page 1 of 2 12 LastLast

Similar Threads

  1. how to make a cell write protected in excel??
    By USTAAGEE in forum Ask an Expert
    Replies: 1
    Last Post: 30th December 2013, 03:13 PM
  2. Excel Tips (Change Active Cell Name)
    By Khalid_ngo in forum Urdu Tutorials & Designing
    Replies: 47
    Last Post: 18th September 2013, 10:10 PM
  3. Change excel cell color
    By umerao in forum Ask an Expert
    Replies: 3
    Last Post: 27th June 2010, 09:22 AM
  4. MS EXCEL : Name of Cell
    By Mubashir Aziz in forum Tips and Tricks
    Replies: 6
    Last Post: 3rd August 2009, 08:13 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
  •