chriscmartin
New Member
- Joined
- Sep 26, 2014
- Messages
- 13
I am very new to macros and would like some help please. (I want this to run on Excel 2000 on an XP machine)
I have a macro that imports some data from a set file to my sells starting at A6.
My question is how do I tell my macro to check if there is data in cell A6 and if there is delete all data in cells a6:F1000 and if there is no data to skip to the next bit of the macro?
This is the macro I currently have.
Sub ImportGunData()
'
' ImportGunData Macro
'
'
Range("A6:D560").Select
Selection.QueryTable.Delete
Selection.ClearContents
Range("A6").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;L:\02 Application Development\Chris\StockCheckData.txt", Destination:= _
Range("$A$6"))
.Name = "StockCheckData"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = False
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFileStartRow = 1
.TextFileParseType = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(9, 2, 2, 1, 4, 2, 2, 9)
.TextFileFixedColumnWidths = Array(1, 5, 6, 1, 6, 6, 5)
.Refresh BackgroundQuery:=False
End With
End Sub
I have a macro that imports some data from a set file to my sells starting at A6.
My question is how do I tell my macro to check if there is data in cell A6 and if there is delete all data in cells a6:F1000 and if there is no data to skip to the next bit of the macro?
This is the macro I currently have.
Sub ImportGunData()
'
' ImportGunData Macro
'
'
Range("A6:D560").Select
Selection.QueryTable.Delete
Selection.ClearContents
Range("A6").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;L:\02 Application Development\Chris\StockCheckData.txt", Destination:= _
Range("$A$6"))
.Name = "StockCheckData"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = False
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFileStartRow = 1
.TextFileParseType = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(9, 2, 2, 1, 4, 2, 2, 9)
.TextFileFixedColumnWidths = Array(1, 5, 6, 1, 6, 6, 5)
.Refresh BackgroundQuery:=False
End With
End Sub