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

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Status
Not open for further replies.

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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