row highlight code doesnt work in Shared WorkBook

Krishnab4u

New Member
Joined
Jul 16, 2018
Messages
34
Dear All,
Following code is to highlight the Row in the given range when a cell is selected.
This codes works perfectly alright until the time the workbook is Shared.
"Application defined or Object defined error" is shown when the workbook is Shared.

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim rownnumber As Integer
'Dim AcSheet As Worksheet


rownumber = ActiveCell.Row


If Application.Intersect(ActiveCell, [DATAHEADER]) Is Nothing Then
If Application.Intersect(ActiveCell, [MAINTABLE]) Is Nothing Then
If ActiveCell.Value <> "" Then
    If ActiveSheet.Protect = True Then
    ActiveSheet.Unprotect Password:=""
    ActiveSheet.Protect AllowFormattingCells:=True
    ActiveSheet.Protect AllowFiltering:=True
    Range("B3:Z500").Interior.ColorIndex = xlNone
    Range("B" & rownumber & ":Z" & rownumber).Interior.Color = RGB(204, 255, 153)
    ActiveSheet.Protect AllowFiltering:=True
    ActiveSheet.Protect Password:=""
    Else
    ActiveSheet.Protect AllowFormattingCells:=True
    Range("B3:Z500").Interior.ColorIndex = xlNone
    ActiveSheet.Range("B" & rownumber & ":Z" & rownumber).Interior.Color = RGB(204, 255, 153)
    ActiveSheet.Protect Password:=""
    End If
End If
End If
End If




End Sub

Please help, what is wrong.

Regards
Krishnamoorthy S
 
Last edited:

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
This I think you will find, just one of the many limitations of sharing a workbook and why many here would advise against using this option.

Sheet / Workbook protection in place when the workbook is shared remains in place and cannot I believe be unprotected with VBA whilst in sharing mode & this may explain the error you have. But others here may have further understanding of the issue.

You can find out more about workbook sharing by searching: “Features unavailable in a shared workbook”

Hope Helpful

Dave
 
Upvote 0
Cross posted https://www.excelforum.com/excel-pr...ight-code-doesnt-work-in-shared-workbook.html

While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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