melodramatic
Board Regular
- Joined
- Apr 28, 2003
- Messages
- 180
- Office Version
- 365
- Platform
- Windows
I'm running a macro to simply put data into a table quickly, and am getting a Run-time error '1004': stating I've got a protected sheet. No, I dont'!
While the sheet is protected, I clearly run the code to unprotect it before the input, then re-protect it after. And that code is working. When the macro bombs ou
My coding from the beginning is as follows:
I first tried running the unprotect code as the following (but that didn't work, either):
While the sheet is protected, I clearly run the code to unprotect it before the input, then re-protect it after. And that code is working. When the macro bombs ou
My coding from the beginning is as follows:
VBA Code:
Private Sub CommandButton1_Click()
'This macro adds to the bank
Dim pwd As String
Dim nextrow As Long
Dim playername As String
Dim money As Long
pwd = Range("K2")
nextrow = Range("L2")
playername = Range("B2")
money = Range("B3")
Worksheets("Activity").Visible = True
Worksheets("Activity").Unprotect Password:=pwd
Worksheets("Activity").Select
MsgBox nextrow
Range("A" & nextrow).Value = playername
Range("B" & nextrow).Value = Date
Range("C" & nextrow).Value = money
Range("D" & nextrow).Value = "Add"
Range("F" & nextrow).Value = Environ("username")
ActiveSheet.Protect Password:=pwd
Worksheets("Balances").Select
Worksheets("Activity").Visible = False
I first tried running the unprotect code as the following (but that didn't work, either):
VBA Code:
Worksheets("Activity").Visible = True
Worksheets("Activity").Select
ActiveSheet.Unprotect Password:=Pwd