Results 1 to 7 of 7

Thread: fill in cells according to selected optionbutton

  1. #1
    Senior Member
    Join Date
    Mar 2013
    Posts
    107
    Rep Power
    12

    fill in cells according to selected optionbutton

    Hi

    I have the cells fill in with color for Production,Planned Stop and Internal for Machine Stoppage......

    1. How can the code be changed so that when Machine Stoppage is used it fills in the cells (eg XFLOW A Sheet) with color depending on which is selected between Internal or External...i can get it to fill in for Internal but not External

    2. When Daily Total is selected (commandbutton) it also colors the rows where all Sum Totals are ... can the rows which have any Totals and Grand Totals entered have NO color in these rows

    Thanks

    PP
    Attached Files Attached Files

  2. #2
    Senior Member
    Join Date
    Mar 2013
    Posts
    107
    Rep Power
    12
    Last edited by DocAElstein; 09-22-2023 at 04:12 PM.

  3. #3
    Moderator
    Join Date
    Jul 2012
    Posts
    156
    Rep Power
    12
    Code:
                With .Range("B" & Rows.Count).End(xlUp)
                    .Offset(, 1).Resize(, 16).Interior.ColorIndex = 34
                    .Offset(, IIf(OptionButton4, 8, 13)).Resize(, 5).Interior.ColorIndex = xlNone
                End With
    Code:
    Sub SubTotalize()
       
        With Sheets("XFLOW A")
           .Unprotect Password:="abc"
           .Range("B7:Q" & .Cells(Rows.Count, 2).End(xlUp).Row).Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Array(3, 4, 7, 12, 16), Replace:=True, PageBreaks:=False, SummaryBelowData:=True
            With .Range("B" & Rows.Count).End(xlUp)
                .Offset(-1, 1).Resize(2, 16).Interior.ColorIndex = xlNone
            End With
           .Protect UserInterfaceOnly:=True, Password:="abc"
        End With
        
    End Sub
    Last edited by bakerman; 09-13-2013 at 06:27 AM.

  4. #4
    Senior Member
    Join Date
    Mar 2013
    Posts
    107
    Rep Power
    12
    Thanks Bakerman

    I am confident this is the last part and the workbook is completed

    If i run this code below with no entries in the data sheet it brings up an error...can something be added in the code so that if no data is on the sheet it brings up a message "no data to sum" .. this will stop the error

    Code:
    
    Sub SubTotalize()
       
        With Sheets("XFLOW A")
           .Unprotect Password:="abc"
           .Range("B7:Q" & .Cells(Rows.Count, 2).End(xlUp).Row).Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Array(3, 4, 7, 12, 16), Replace:=True, PageBreaks:=False, SummaryBelowData:=True
            With .Range("B" & Rows.Count).End(xlUp)
                .Offset(-1, 1).Resize(2, 16).Interior.ColorIndex = xlNone
            End With
           .Protect UserInterfaceOnly:=True, Password:="abc"
        End With
        
    End Sub

  5. #5
    Senior Member
    Join Date
    Mar 2013
    Posts
    107
    Rep Power
    12
    Another

    On the data sheet XFLOW A for 13/9/2013 & 14/9/2013 for Total the rows are blue....can all rows with either Total or Grand Total have no color

    Thanks again
    Attached Files Attached Files

  6. #6
    Moderator
    Join Date
    Jul 2012
    Posts
    156
    Rep Power
    12
    Put this on top off SubTotalize.
    Code:
    If Sheets("XFLOW A").Range("B6").CurrentRegion.Rows.Count = 2 Then Exit Sub

  7. #7
    Senior Member
    Join Date
    Mar 2013
    Posts
    107
    Rep Power
    12
    Thanks bakerman

    Can this one be fixed...if so this is finished

    On the data sheet XFLOW A for 13/9/2013 & 14/9/2013 for Total the rows are blue....can all rows with either Total or Grand Total have no color

    Thanks again
    Attached Files Attached Files

Similar Threads

  1. Replies: 1
    Last Post: 08-20-2013, 04:31 PM
  2. Replies: 9
    Last Post: 08-02-2013, 07:55 PM
  3. Unmerge Cells and Fill with Duplicate Values
    By princ_wns in forum Excel Help
    Replies: 3
    Last Post: 10-09-2012, 07:36 AM
  4. Replies: 2
    Last Post: 09-24-2012, 06:24 PM
  5. Replies: 0
    Last Post: 02-27-2012, 01:07 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •