Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Can someone please help and tell me how to correct error message: Runtime
Error '9': Subscript Out Of Range in the following code? I have marked the line where Debug gives the error with 'ERROR ON THIS LINE below. I am trying to run the macro from one workbook and accessing another workbook which is open in the same folder. Thanks Jack Sub ProtectWkshtsFromSeperateFile() 'Counts worksheets and protects worksheets from passwords 'listed in column B on Passwords worksheet in seperate workbook Dim ShPassword As String Dim WkstName As String Const wkb = "C:\Documents and Settings\Jack\My Documents\@excel password test\psw source.xlsm" For i = 1 To Workbooks(wkb).Worksheets.Count 'ERROR ON THIS LINE WkstName = Worksheets(i).Name 'VLookup sheet password on Passwords worksheet ShPassword = Application.WorksheetFunction.VLookup(WkstName, Sheets("Passwords") _ ..Range("A1:B" & Sheets("Passwords").Range("B" & Rows.Count).End(xlUp).Row), 2, False) 'Protect each worksheet with specified password on Passwords worksheet Workbooks(wkb).Worksheets(WkstName).Protect Password:=ShPassword Next i End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
runtime error 9 subscript out of range | Excel Worksheet Functions | |||
runtime error 9 -- subscript out of range | Excel Programming | |||
runtime error 9 subscript out of range #3 | Excel Programming | |||
runtime error 9 out of range subscript #2 | Excel Programming | |||
Runtime Error '9' Subscript out of range HELP | Excel Programming |