vba locking / unlocking selection macro -
i want create macro lock / unlock cells based on locked range property, having trouble firing case null section of statement( first 2 work fine)
sub lockunlockselection() dim c range dim wb workbook dim ws worksheet 'dim lck string 'dim unlck string set wb = activeworkbook set ws = wb.activesheet 'lck = empty 'unlck = empty set c = selection select case c.locked case false c.locked = true msgbox "selection " & c.address & " locked!", vbinformation, date case true c.locked = false msgbox "selection " & c.address & " unlocked!", vbinformation, date case null ' if mix of locked , unlocked c.locked = true msgbox "mix of locked , unlocked cells!" & vblf & vblf & "cells locked!", vbinformation + vbexclamation, "info.." end select end sub
why not firing??
thanks!
solution (if interested):
sub lockunlockselection() dim c range dim wb workbook dim ws worksheet 'dim lck string 'dim unlck string set wb = activeworkbook set ws = wb.activesheet 'lck = empty 'unlck = empty set c = selection if isnull(c.locked) = true ' if mix of locked , unlocked msgbox "mix of locked , unlocked cells!" & vblf & vblf & "cells locked!", vbexclamation + vbmsgboxsetforeground, "info.." c.locked = true else select case c.locked case false c.locked = true msgbox "selection " & c.address & " locked!", vbinformation, date case true c.locked = false msgbox "selection " & c.address & " unlocked!", vbinformation, date end select end if end sub
Comments
Post a Comment