Hi
I have a workbook with macros.
If a user opens the workbook and does not enable macros, then a sheet named "Macros disabled" will be shown and nothing more.
If they do enable macros, then I have a macro that hides the "Macros disabled" sheet and shows three other sheets called "Information" "Prices" and "Copied Prices".
I have another code that Activates the "Information" Sheet and locks the "Prices" sheet with UserInterFaceOnly.
Now I wanted a macro to select certain cells within the "Prices" sheet depending on choices made in other cells in the same sheet, and that works.
But when I open the workbook I get a Method Of Range Class Failed error, and I think but I am not sure, that it is because that I am trying to select cells in a sheet ("Prices") that is not active.
Here are the code in my "Prices" Sheet that selects the cells:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Worksheets("Prices").Range("B19,B23,B24,B25")) Is Nothing Then
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
Target.Offset(1).Select
End If
If Worksheets("Prices").Range("B7").Value = "YES" Then
If Not Intersect(Target, Worksheets("Prices").Range("B7,B8")) Is Nothing Then
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
Target.Offset(1).Select
End If
End If
If Worksheets("Prices").Range("B7").Value = "NO" Then
If Not Intersect(Target, Worksheets("Prices").Range("B7")) Is Nothing Then
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
Target.Offset(3).Select
End If
End If
If Not Intersect(Target, Worksheets("Prices").Range("B9,B26")) Is Nothing Then
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
Target.Offset(3).Select
End If
End Sub
Can anybody help me with that?
I have a workbook with macros.
If a user opens the workbook and does not enable macros, then a sheet named "Macros disabled" will be shown and nothing more.
If they do enable macros, then I have a macro that hides the "Macros disabled" sheet and shows three other sheets called "Information" "Prices" and "Copied Prices".
I have another code that Activates the "Information" Sheet and locks the "Prices" sheet with UserInterFaceOnly.
Now I wanted a macro to select certain cells within the "Prices" sheet depending on choices made in other cells in the same sheet, and that works.
But when I open the workbook I get a Method Of Range Class Failed error, and I think but I am not sure, that it is because that I am trying to select cells in a sheet ("Prices") that is not active.
Here are the code in my "Prices" Sheet that selects the cells:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Worksheets("Prices").Range("B19,B23,B24,B25")) Is Nothing Then
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
Target.Offset(1).Select
End If
If Worksheets("Prices").Range("B7").Value = "YES" Then
If Not Intersect(Target, Worksheets("Prices").Range("B7,B8")) Is Nothing Then
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
Target.Offset(1).Select
End If
End If
If Worksheets("Prices").Range("B7").Value = "NO" Then
If Not Intersect(Target, Worksheets("Prices").Range("B7")) Is Nothing Then
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
Target.Offset(3).Select
End If
End If
If Not Intersect(Target, Worksheets("Prices").Range("B9,B26")) Is Nothing Then
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
Target.Offset(3).Select
End If
End Sub
Can anybody help me with that?