I borrowed some code that was in a worksheet that the people that came before me created...
I have adapted it to work for me in another situation but I am wanting to modify it.
Basically I have a data collection machine that creates csv files with information. I am wanting to extract information from those csv files and if all of the information is present it works beautifully. I find though that we don't always collect a comment field or description field and that is where I get the error "The extract range has a missing or invalid field name".
So in the below it is looking in the datalist for four fields. If not all four are present, it doesn't work. Can the below be modified to extract a certain field if it is present in the csv and leave it blank if it is not?
Selection.SpecialCells(xlCellTypeLastCell).Select
Ref = ActiveCell.Address
r_num = ActiveCell.Row - 1
ActiveWorkbook.Names.Add Name:="Datalist", RefersToR1C1:= _
Range("A2:" & Ref)
Sheets.Add After:=ActiveSheet
Range("B1").FormulaR1C1 = "Feature"
Range("C1").FormulaR1C1 = "Description"
Range("D1").FormulaR1C1 = "Type"
Range("E1").FormulaR1C1 = "Comment"
Range("Datalist").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range( _
"B1:E1"), Unique:=False
I have adapted it to work for me in another situation but I am wanting to modify it.
Basically I have a data collection machine that creates csv files with information. I am wanting to extract information from those csv files and if all of the information is present it works beautifully. I find though that we don't always collect a comment field or description field and that is where I get the error "The extract range has a missing or invalid field name".
So in the below it is looking in the datalist for four fields. If not all four are present, it doesn't work. Can the below be modified to extract a certain field if it is present in the csv and leave it blank if it is not?
Selection.SpecialCells(xlCellTypeLastCell).Select
Ref = ActiveCell.Address
r_num = ActiveCell.Row - 1
ActiveWorkbook.Names.Add Name:="Datalist", RefersToR1C1:= _
Range("A2:" & Ref)
Sheets.Add After:=ActiveSheet
Range("B1").FormulaR1C1 = "Feature"
Range("C1").FormulaR1C1 = "Description"
Range("D1").FormulaR1C1 = "Type"
Range("E1").FormulaR1C1 = "Comment"
Range("Datalist").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range( _
"B1:E1"), Unique:=False