Results 1 to 5 of 5

Macro in a Toggle Button

Threaded View

  1. #1
    Registered User
    Join Date
    07-19-2009
    Location
    New Yoek
    MS-Off Ver
    Excel 2003
    Posts
    35

    Macro in a Toggle Button

    Hello ,

    I was wondering if it's possible to use this macro code in a toggle to perform this action when it's true and when the toggle is click again it can undo it.

    This macro does lookups and finds the max on sets of value when it is run and i was wondering if by clicking the button again it can undo what it placed in the cells...

    Any thoughts?

    Gratias...

    Sub LargestGPW() 
         
        ActiveSheet.Unprotect Password:="PWD" 
         
        Dim lngLastRow As Long, rngData As Range, rngCell As Range 
        lngLastRow = Cells(Rows.Count, "g").End(xlUp).row 
        On Error Resume Next 
        Set rngData = Range("G26:G" & lngLastRow).SpecialCells(xlCellTypeBlanks) 
        On Error Goto 0 
        If Not rngData Is Nothing Then 
            For Each rngCell In rngData 
                With rngCell 
                    .Offset(3, -2).FormulaR1C1 = "=LOOKUP(2,1/((R27C7:R" & lngLastRow & "C7=R[-2]C[2])*(R27C28:R" & _ 
                    lngLastRow & "C28=R[1]C)),R27C11:R" & lngLastRow & "C11)" 
                    .Offset(4, -2).FormulaArray = "=MAX(IF(R27C7:R" & lngLastRow & "C7=R[-3]C[2],R27C28:R" & lngLastRow & "C28))" 
                     
                End With 
            Next rngCell 
        End If 
         
        ActiveSheet.Protect Password:="PWD", 
         
    End Sub
    Last edited by Preatorian; 07-28-2009 at 09:21 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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