请高手们帮看看,提示运行错误9,下标超界。(目的是自动生成一TXT文件)
Set SelRange = Application.SelectionselStartRow = SelRange.Row
selEndRow = SelRange.Rows(SelRange.Rows.Count).Row
FileName = "\\桌面\价格导入文件"
FileName = FileName & "\" & Sheets("stand").Cells(2, 2).Value & ".txt"
intCol = 4
FileNum = FreeFile
Open FileName For Output As #FileNum
For i = selStartRow To selEndRow
cTxt = ""
For j = 1 To intCol
If j = 4 Then
cTxt = cTxt & Sheets("stand").Cells(i, j).Value
ElseIf j = 2 Then
cTxt = cTxt & "000" & Sheets("stand").Cells(i, j).Value & Chr(9)
Else
cTxt = cTxt & Sheets("stand").Cells(i, j).Value & Chr(9)
End If
Next j
Print #FileNum, Left(cTxt, Len(cTxt))
Next i
Close #FileNum
Sheets("stand").Select
Application.DisplayAlerts = False
ActiveWindow.SelectedSheets.Delete
Application.DisplayAlerts = True
End Sub