Good day everyone, I have a following Worksheet_Activate module under sheet 1, which performs a few actions. But one of he key things it does is convert formulas to text. However it does not seem to work. Would anyone be able to have a look and tell me if potential sources of error exist in the code?
Private Sub Worksheet_Activate()
'verify the user: whether it is requestor or sample group member or both(just Sarah)
'and set type of buttons to be available
If first_open_choose_buttons = False And Val(ThisWorkbook.Worksheets(1).Cells(1, 12).Value) = 1 Then
On Error GoTo errhandler:
Open "C:\BrochPasswd.txt" For Input As #1
Close #1
If usernm = "sarfor" Then
prmt1 = "Hello Sarah!" & Chr(10) + Chr(13) & "You open this document to SAVE_AS in GM [Y] or PROCESS IN BROCHURE [N]?"
notif1 = MsgBox(prmt1, vbYesNo, "CHOOSE OPPENING MODE")
If notif1 = vbYes Then
'check if formulas have been changed in text Value 2=NO, 1=YES
If Val(ThisWorkbook.Worksheets(1).Cells(2, 12).Value) = 2 Then
ThisWorkbook.Worksheets(1).Cells(2, 12).Value = 1
'tooked from Red Button. Very first code to replace formulas with data when requestor save_as SR
Range("A1:Z500").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Cells(1, 1).Select
ThisWorkbook.Worksheets(1).Protect (dwp)
End If
'END check if formulas has been changed in text Value 2=NO, 1=YES
CommandButton2.Visible = False
CommandButton3.Visible = True
choose_user_button2 = False
Else
CommandButton2.Visible = True
CommandButton3.Visible = False
choose_user_button2 = True
End If
Else
CommandButton2.Visible = True
CommandButton3.Visible = False
choose_user_button2 = True
End If
first_open_choose_buttons = True
Exit Sub
errhandler:
'check if formulas has been changed in text Value 2=NO, 1=YES
If Val(ThisWorkbook.Worksheets(1).Cells(2, 12).Value) = 2 Then
ThisWorkbook.Worksheets(1).Cells(2, 12).Value = 1
Range("B4:B8").Copy
Range("B4").PasteSpecial Paste:=xlPasteValues
Range("I5:I9").Copy
Range("I5").PasteSpecial Paste:=xlPasteValues
Cells(1, 1).Select
ThisWorkbook.Worksheets(1).Protect (dwp)
End If
'END check if formulas has been changed in text Value 2=NO, 1=YES
CommandButton2.Visible = False
CommandButton3.Visible = True
choose_user_button2 = False
first_open_choose_buttons = True
End If
End Sub
Bookmarks