View Single Post
 
Old 09-26-2020, 08:21 PM
Syed Shabbir Syed Shabbir is offline Windows 10 Office 2007
Novice
 
Join Date: Sep 2020
Posts: 1
Syed Shabbir is on a distinguished road
Question Declare wBk as workbook. Set wBk = workbooks("NewBook.xls") gives error: Subscript out of range.

Sub main()

Dim i As Integer
Dim wrk As Workbook
Dim wsh As Worksheet, wrk_Name, wsh_Name, prmpt As String

prmpt = "Enter Workbook name:"

wrk_Name = Application.InputBox(prmpt)

prmpt = "Enter Worksheet name:"

wsh_Name = Application.InputBox(prmpt)


Set wrk = Workbooks(wrk_Name) 'This line gives error

'....
end sub
Reply With Quote