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

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -