Method Of Range Class Failed

Status
Not open for further replies.

CV899000

Board Regular
Joined
Feb 11, 2016
Messages
98
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?
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Status
Not open for further replies.

Forum statistics

Threads
1,223,903
Messages
6,175,287
Members
452,631
Latest member
a_potato

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top