hi all
i have the below vba code
I would like to add that if the cell value of A1 of the particular file that I'm opening, is blank then it runs a different function and if the cell value in b1 is blank then it runs a third function or a different sub i can split it if needed, the only reason I'm using functions is because if i hit cancel on the open dialog it doesn't error out
i have the below vba code
VBA Code:
Function test() As Boolean
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim MyFile As Variant
ChDrive "C:"
MyFile = Application.GetOpenFilename
If MyFile = False Then
test = False
Exit Function
Else
test = True
End If
Workbooks.OpenText FileName:=MyFile _
, Origin:=437, StartRow:=1 _
, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:=False _
, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 2), Array(2, 1), _
Array(3, 1), Array(4, 2), Array(5, 1), Array(6, 1), Array(7, 2), Array(8, 2), Array(9, 2), _
Array(10, 1), Array(11, 1), Array(12, 1), Array(13, 1), Array(14, 2), Array(15, 1), Array( _
16, 1), Array(17, 1)), TrailingMinusNumbers:=True
Cells.Select
Cells.EntireColumn.AutoFit
I would like to add that if the cell value of A1 of the particular file that I'm opening, is blank then it runs a different function and if the cell value in b1 is blank then it runs a third function or a different sub i can split it if needed, the only reason I'm using functions is because if i hit cancel on the open dialog it doesn't error out