L
Les Stout
Good day, i would just like to know if it is good practice to use "On
Error GoTo" within your code e.g.
Sub ChangeLcs()
' Open LCS list and modify
'
Application.WindowState = xlMinimized
Application.DisplayAlerts = False
'----- If there is no file goto NoFile MsgBox -----------
On Error GoTo NoFile
'----- If there is a file open it to process ------------ ChDir
"L:\LCS"
Workbooks.OpenText FileName:="L:\LCS\" & myLCS & ".xls",
Origin:=437, StartRow _
:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False,
Comma:=False _
, Space:=False, Other:=True, OtherChar:="|",
FieldInfo:=Array(Array(1, 1 _
), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6,
1), Array(7, 4), Array(8, 4), _
Array(9, 1), Array(10, 1)), TrailingMinusNumbers:=True
With Rows("1:1")
.Font.Bold = True
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Columns("A:J").EntireColumn.AutoFit
Range("A2").Select
ShowFileAccessInfoLCS
'----- Message if there is no LCS file available --------NoFile:
MsgBox "Sorry, there is no LCS report for the project you selected
!"
End Sub
Les Stout
Error GoTo" within your code e.g.
Sub ChangeLcs()
' Open LCS list and modify
'
Application.WindowState = xlMinimized
Application.DisplayAlerts = False
'----- If there is no file goto NoFile MsgBox -----------
On Error GoTo NoFile
'----- If there is a file open it to process ------------ ChDir
"L:\LCS"
Workbooks.OpenText FileName:="L:\LCS\" & myLCS & ".xls",
Origin:=437, StartRow _
:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False,
Comma:=False _
, Space:=False, Other:=True, OtherChar:="|",
FieldInfo:=Array(Array(1, 1 _
), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6,
1), Array(7, 4), Array(8, 4), _
Array(9, 1), Array(10, 1)), TrailingMinusNumbers:=True
With Rows("1:1")
.Font.Bold = True
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Columns("A:J").EntireColumn.AutoFit
Range("A2").Select
ShowFileAccessInfoLCS
'----- Message if there is no LCS file available --------NoFile:
MsgBox "Sorry, there is no LCS report for the project you selected
!"
End Sub
Les Stout