stuartk812
New Member
- Joined
- Nov 4, 2021
- Messages
- 7
- Office Version
- 2016
- Platform
- Windows
Hi there,
I am TOTALLY new to VBA and have never used it before. Following some googling, I've been able to create a button which clears certain data - which I'm happy about!
I now want to password protect this button though, so that if it is clicked, the user is prompted to enter a password. If they get the password wrong, or cancel out of the box, no data will be cleared.
What I have so far is :
Sub Clearcells()
Range("G8:G30").ClearContents
Range("I8:I30").ClearContents
Range("K8:K30").ClearContents
Range("M8:M30").ClearContents
End Sub
I am TOTALLY new to VBA and have never used it before. Following some googling, I've been able to create a button which clears certain data - which I'm happy about!
I now want to password protect this button though, so that if it is clicked, the user is prompted to enter a password. If they get the password wrong, or cancel out of the box, no data will be cleared.
What I have so far is :
Sub Clearcells()
Range("G8:G30").ClearContents
Range("I8:I30").ClearContents
Range("K8:K30").ClearContents
Range("M8:M30").ClearContents
End Sub