Hi Everyone. Having an issue with my vba below. Our developers every now and then (as per normal) update our system (crystal reports) by adding or deleting extra columns, I export these reports to a CSV Excel file then run my macro on the csv to delete and manipulate the columns and data within.
I trying to figure a way of amending my macro to prevent them from failing every time they insert a few extra columns, FYI the raw csv columns have headers which I eventually rename to something more meaningful and relevant.
Its been suggested that I try using advanced filtering with vba, but I am really not up on this method to take it any further so would need help with this route if this is a valid option.
Otherwise, here's a simple sample of what I have so far.
Code: <code> ' I really need the VBA to "FIND" the column header rather than test a specific column header value and data within.
If Range("O1").Value = "Some_HeaderInfo" And Range("O2").Value = "DATA_001" <code>And Range("O3").Value = "DATA_003"</code> Then
Application.CutCopyMode = False
Columns("O:P").Select
Selection.Delete Shift:=xlToLeft
end if</code>
I trying to figure a way of amending my macro to prevent them from failing every time they insert a few extra columns, FYI the raw csv columns have headers which I eventually rename to something more meaningful and relevant.
Its been suggested that I try using advanced filtering with vba, but I am really not up on this method to take it any further so would need help with this route if this is a valid option.
Otherwise, here's a simple sample of what I have so far.
Code: <code> ' I really need the VBA to "FIND" the column header rather than test a specific column header value and data within.
If Range("O1").Value = "Some_HeaderInfo" And Range("O2").Value = "DATA_001" <code>And Range("O3").Value = "DATA_003"</code> Then
Application.CutCopyMode = False
Columns("O:P").Select
Selection.Delete Shift:=xlToLeft
end if</code>
Last edited: