Good Afternoon Experts, I need some help with a code I created. I am parsing out a text file and placing it in Excel on seperate sheets. In my attempt to do so, I get an error 'Subscript Out of Range' I have never seen it before, but is pointing to this line of code: "Set ws1 = wbs.workSheets(XA)". Here is the full code: Can anyone help please
excel.Visible = false
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set wbs = excel.Workbooks.Open(sXLS)
'Add Spreadsheet to Workbook
excel.WorkSheets(1).Name = "XA"
excel.WorkSheets(2).Name = "XB"
excel.WorkSheets(3).Name = "XC"
row = 2
Set ws1 = wbs.workSheets(XA) 'Setup variable worksheet
Set ws2 = wbs.workSheets(XB)
Set ws3 = wbs.workSheets(XC)
Set objFile = objFSO.OpenTextFile(ObjDialog.FileName, 1, True)
Do While Not objFile.AtEndOfStream
sText = objFile.ReadLine