I have a task to write an Excel macro to match a specific import template for a customer of mine. I have a large quantity of data and only some of it is needed. I have managed to write the VB to eliminate columns, rows, etc to fit the criteria I need.
What I do not know how to do, is add a row in the row 1 spot that will add data to each of the cells in the correct order.
For example I would want to add "OrderID" "CompanyName" "Contact" and "Address1" in successive cells across the row. Is this possible?
Also I would want to add new columns into the sheet, is there a way to specify where I add them?
The code I am currently using:
Sub Macro1()
'
'
' Keyboard Shortcut: Ctrl+a
Dim i As Long
Dim LastRow As Long
LastRow = ActiveCell.SpecialCells(xlCellTypeLastCell).Row
For i = LastRow To 1 Step -1
If Cells(i, 1).Value <> "CUST" Then
Rows(i).Delete
End If
Next i
Columns(1).EntireColumn.Delete
Columns(2).EntireColumn.Delete
Columns(3).EntireColumn.Delete
Columns(5).EntireColumn.Delete
Columns(5).EntireColumn.Delete
Columns(5).EntireColumn.Delete
Columns(5).EntireColumn.Delete
Columns(5).EntireColumn.Delete
Columns(5).EntireColumn.Delete
Columns(5).EntireColumn.Delete
Columns(4).EntireColumn.Delete
Columns(4).EntireColumn.Delete
End Sub