Chris Gunner
Chris Gunner

Reputation: 167

Activate Range, Allow Edit, Continue

As a secondary method to my question here: Show Cell Range on UserForm; then update

I would like to have a macro that selects a range, and activates it, but allows the user to edit cells in that range. Then, it needs to have a button that moves onto the next range. Is there a way to keep a form visible, but allow the user access to a range?

And if that's possible, can I temporarily lock all other cells than those in the range while the updating is taking place, to avoid errors?

Upvotes: 0

Views: 2927

Answers (1)

Matthew Rathbone
Matthew Rathbone

Reputation: 8269

You can show a form in 'modeless' state, which means that the user is not locked to that form:

Dim interactionForm As New DemoForm

interactionForm.Show vbModeless

You can also programatically lock and unlock certain cell ranges depending on what you want to do:

Dim bigRange As Range
Set bigRange = Sheet1.Range("SomeRange")

Sheet1.Cells.Locked = True
bigRange.Locked = False
Sheet1.Protect "password1" ' add other options here

Using this you can lock all cells on a sheet, but unlock the range you want them to edit. You could even colour that range Green or some other colour to enforce what you want them to do.

Just don't forget to unlock everything when you're done!

Sheet1.Unprotect "password1"
Sheet1.Cells.Locked = False

Upvotes: 1

Related Questions