ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Edit Macro to work for other Workbooks (https://www.excelbanter.com/excel-programming/295233-edit-macro-work-other-workbooks.html)

DAA[_2_]

Edit Macro to work for other Workbooks
 
Public OldRng

Private Sub Workbook_Open()
ReDim OldRng(20) 'allow for upto 20 worksheets
End Sub
The macro below changes the pointer color. It was provided
by Mr. Bob Phillips today. I created an add-in file for it
hoping that it would work when I open another WORKBOOK. It
didn't work. Please help. Thanks.

Private Sub Workbook_SheetSelectionChange(ByVal Sh As
Object, ByVal Target
As Range)
Dim ThisRng

On Error Resume Next
Set ThisRng = OldRng(Sh.Index)
If Not ThisRng Is Nothing Then
ThisRng.Interior.ColorIndex = xlNone
End If
Target.Interior.ColorIndex = 6
Set OldRng(Sh.Index) = Target

End Sub

BrianB

Edit Macro to work for other Workbooks
 
For this to work you need to have your code included in th
SheetSelectionChange event code of each workbook. ...
Or at least a Run statement there pointing to a macro in anothe
workbook. (See Run Method in VBA Help)

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 08:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com