K
Kiba
I have a workbook with a few sheets on it. One sheet is mostly a page to
enter data. I have a macro that if the cell isn't blank and you edit or
delete it. It prompts and r u sure message. only if you select multiple
cells then it gives an error/debug message. Here is my code.
_____________________________________________________
Private SaveValue
Private Sub Worksheet_Activate()
SaveValue = ActiveCell.Value
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Static Mech As Boolean
If SaveValue = "" Then Exit Sub
If Mech = True Then
Mech = False
Exit Sub
End If
If MsgBox("Are you sure you want to change that value?", vbYesNo) = vbNo
Then
Mech = True
Target.Value = SaveValue
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
SaveValue = Target.Value
End Sub
_________________________________________________________
On another page is a few cells that have data entered but most pull
information from the other page. Whenever I change a cell with a formula in
it I get that error/debug message and here's my code for that sheet.
___________________________________________________________
Private SaveValue
Private Sub Worksheet_Activate()
SaveValue = ActiveCell.Value
Dim cell As Range
Application.ScreenUpdating = False
With ActiveSheet.UsedRange
.Rows.Hidden = False
For Each cell In Range("A1:A60")
If cell.Value = "" Then _
cell.EntireRow.Hidden = True
Next cell
End With
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Static Mech As Boolean
If SaveValue = "" Then Exit Sub
If Mech = True Then
Mech = False
Exit Sub
End If
If MsgBox("Are you sure you want to change that value?", vbYesNo) = vbNo
Then
Mech = True
Target.Value = SaveValue
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
SaveValue = Target.Value
End Sub
_________________________________________________________
I'm still fairly new to this so I appreciate any help. Thanks.
enter data. I have a macro that if the cell isn't blank and you edit or
delete it. It prompts and r u sure message. only if you select multiple
cells then it gives an error/debug message. Here is my code.
_____________________________________________________
Private SaveValue
Private Sub Worksheet_Activate()
SaveValue = ActiveCell.Value
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Static Mech As Boolean
If SaveValue = "" Then Exit Sub
If Mech = True Then
Mech = False
Exit Sub
End If
If MsgBox("Are you sure you want to change that value?", vbYesNo) = vbNo
Then
Mech = True
Target.Value = SaveValue
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
SaveValue = Target.Value
End Sub
_________________________________________________________
On another page is a few cells that have data entered but most pull
information from the other page. Whenever I change a cell with a formula in
it I get that error/debug message and here's my code for that sheet.
___________________________________________________________
Private SaveValue
Private Sub Worksheet_Activate()
SaveValue = ActiveCell.Value
Dim cell As Range
Application.ScreenUpdating = False
With ActiveSheet.UsedRange
.Rows.Hidden = False
For Each cell In Range("A1:A60")
If cell.Value = "" Then _
cell.EntireRow.Hidden = True
Next cell
End With
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Static Mech As Boolean
If SaveValue = "" Then Exit Sub
If Mech = True Then
Mech = False
Exit Sub
End If
If MsgBox("Are you sure you want to change that value?", vbYesNo) = vbNo
Then
Mech = True
Target.Value = SaveValue
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
SaveValue = Target.Value
End Sub
_________________________________________________________
I'm still fairly new to this so I appreciate any help. Thanks.