How do I use a sub from a different work book
error-handling, excel, vba
Solution
Here's how you run a macro from your personal workbook:
Application.Run "PERSONAL.XLSB!Password", Target
[EDIT] It's worth noting that instead of a loop to build the * string, you could do this:
Public Sub Password(ByVal Target As Range)
Dim sMask as String
sMask = Mid(WorksheetFunction.Rept(";""" & String(Len(Target.Value), "*") & """", 4), 2)
Target.NumberFormat = sMask
End Sub
Problem
In a PERSONAL.XLSB workbook, I have this code: ``` Public Sub Password(ByVal Target As Range) a = "" For n = 1 To Len(Target) a = a & "*" Next n Target.NumberFormat = """" & a & """;""" & a & """;""" & a & """;""" & a & """" End Sub ``` In my new workbook, I have this code: ``` Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = Info.Range("AA9").Address Then Workbooks("PERSONAL.XLSB").Password Target End If End Sub ``` I keep getting an error saying, `Compile error: Invalid use of property`