+ Reply to Thread
Results 1 to 10 of 10

Repeat the same script on 48 rows, counting CF cell colors

  1. #1
    Registered User
    Join Date
    09-25-2016
    Location
    Florida
    MS-Off Ver
    365
    Posts
    51

    Repeat the same script on 48 rows, counting CF cell colors

    The following script works like a champ counting conditionally formatted colored cells (2 buttons/scripts) but I need it to repeat on 24 different rows and hopefully not 24 different buttons/scripts. I could do it repeating the script 24 times and manually adjusting coding for each row and then call each script with one button but it seems there would be a better way to maybe loop to the end? Also, not all rows need to be counted. If there is a name in cells B12 through B35 then the script would need to stop when it reaches an empty cell, there wouldn't be anything to count.

    Thanks in advance.
    Andy

    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor
    Join Date
    11-29-2022
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    430

    Re: Repeat the same script on 48 rows, counting CF cell colors

    How about:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    09-25-2016
    Location
    Florida
    MS-Off Ver
    365
    Posts
    51

    Re: Repeat the same script on 48 rows, counting CF cell colors

    Went to test your code and the following variable "ws" wasn't defined. Not sure what to declare it as.

    If ws.Cells(i, 2) <> "" Then

  4. #4
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,604

    Re: Repeat the same script on 48 rows, counting CF cell colors

    Try:
    Please Login or Register  to view this content.
    Ben Van Johnson

  5. #5
    Registered User
    Join Date
    09-25-2016
    Location
    Florida
    MS-Off Ver
    365
    Posts
    51

    Re: Repeat the same script on 48 rows, counting CF cell colors

    Proton,

    That worked pretty nicely except it put all the counts in column "A". Probably because my commented code stated the results to go into cell A12 where it should have been in "Z12". So, I corrected the offset from -3 to 22 and it puts the results in the Z column accordingly per row.

    But, I should have also mentioned that this section is for the "Gross Skins" section and stops at row 35. The code as-is went way down the column into the next section which is the "Net Skins" section and those cells, which will need the same script procedure, are rows 52-75, with the same columns as the "Gross Skins". The "Net Skins" pulls entered data from the "Gross Skins" section but the number of skins won by player will obviously be different resulting in running the script there too.

    I'm just not sure where or how to make it stop at row 35 and, if possible, have it do the same in the "Net Skins" section without pressing another button. But I am fine if that's the simplest way.

    Andy

  6. #6
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,604

    Re: Repeat the same script on 48 rows, counting CF cell colors

    I didn't know what the worksheet looked like; I even looked at a few of your previous posts, but found nothing like the current description so I just made up something.
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    09-25-2016
    Location
    Florida
    MS-Off Ver
    365
    Posts
    51

    Re: Repeat the same script on 48 rows, counting CF cell colors

    Hey Ben,

    Initial test works great but I forgot one other detail...the Net Skins is a different RGB color so it didn't count. It is orange (255,192,0).

    I sent you a PM with a link to our website to give you a visual on the skins sheet.

    Andy

  8. #8
    Registered User
    Join Date
    09-25-2016
    Location
    Florida
    MS-Off Ver
    365
    Posts
    51

    Re: Repeat the same script on 48 rows, counting CF cell colors

    I added another IF statement for the RGB and it seems to be working great. I'd like to eliminate the 0's when it doesn't count a color but not a big deal at all.

    I apologize about missing a couple of details and appreciate you quick response as well as the Thomglea's suggested coding. I tried both and your seems to be working best.

    Please Login or Register  to view this content.

  9. #9
    Valued Forum Contributor
    Join Date
    11-29-2022
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    430

    Re: Repeat the same script on 48 rows, counting CF cell colors

    Quote Originally Posted by Andy C. View Post
    Went to test your code and the following variable "ws" wasn't defined. Not sure what to declare it as.

    If ws.Cells(i, 2) <> "" Then
    Sorry, that should be skins.cells. Out of habit, I use ws in my own scripts.

  10. #10
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,604

    Re: Repeat the same script on 48 rows, counting CF cell colors

    Latest mods:
    Please Login or Register  to view this content.

+ 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. counting colors depending on value in another cell
    By rick&morty in forum Excel Programming / VBA / Macros
    Replies: 62
    Last Post: 06-09-2022, 04:34 AM
  2. counting colors depending on value in another cell
    By rick&morty in forum Excel Formulas & Functions
    Replies: 51
    Last Post: 06-02-2022, 02:50 AM
  3. [SOLVED] Need VB script counting colors of highlighted cells.
    By alexgempesaw in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-28-2015, 11:55 PM
  4. Need VB script counting colors of highlighted cells.
    By alexgempesaw in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-28-2015, 05:22 AM
  5. Need VB script counting colors of highlighted cells.
    By alexgempesaw in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-28-2015, 05:22 AM
  6. [SOLVED] repeat counting of blank cells till a cell with number/text
    By joshcct in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-03-2015, 03:33 AM
  7. Repeat script or marco dependent on the value in a cell
    By eltonlaw in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-22-2012, 05:28 AM

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