karthikin
12-16-2011, 05:37 AM
How can i perform delete multiple cols in Excel using VBA.
My approach is like this:
Workbooks.OpenText Filename:="C:\Users\karthic.rangaraj\Desktop\4412_CARQUEF.csv"
' Parse it using comma and semicolon as delimiters
Range(Range("A1"), Range("A1").End(xlDown)).TextToColumns _
DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
Semicolon:=True, Comma:=True, Space:=False, Other:=False, _
FieldInfo:= _
Array(Array(1, 2), Array(2, 2), Array(3, 2), Array(4, 1), Array(5, 2))
' Delete columns of ComputerSerial & UserName
Columns("B:B").Select
Selection.Delete Shift:=xlToLeft
Columns("C:C").Select
Selection.Delete Shift:=xlToLeft
"Computer Name","Computer Serial","User name","Employee Number","Software name" --> this is the first line in the csv file & then i use the above code. It does exactly to remove the quotations, comma etc..but when i want to delete the "Computer Serial","User name" at the same it's not working.
How can i delete B & C cols at the same time??? How can i create a executable macro in my Excel.
Thanks guys!!
My approach is like this:
Workbooks.OpenText Filename:="C:\Users\karthic.rangaraj\Desktop\4412_CARQUEF.csv"
' Parse it using comma and semicolon as delimiters
Range(Range("A1"), Range("A1").End(xlDown)).TextToColumns _
DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
Semicolon:=True, Comma:=True, Space:=False, Other:=False, _
FieldInfo:= _
Array(Array(1, 2), Array(2, 2), Array(3, 2), Array(4, 1), Array(5, 2))
' Delete columns of ComputerSerial & UserName
Columns("B:B").Select
Selection.Delete Shift:=xlToLeft
Columns("C:C").Select
Selection.Delete Shift:=xlToLeft
"Computer Name","Computer Serial","User name","Employee Number","Software name" --> this is the first line in the csv file & then i use the above code. It does exactly to remove the quotations, comma etc..but when i want to delete the "Computer Serial","User name" at the same it's not working.
How can i delete B & C cols at the same time??? How can i create a executable macro in my Excel.
Thanks guys!!