Macro - Insert&Label Column, if the labeled column doesn't exist
Hi Jeff:
Dim XLCell as Range
Set XLCell = Sheets("SheetName").Range("1:1").Find("YOUR
HEADER",,xlValues,xlWhole)
If XLCell Is Nothing Then Sheets("SheetName").Range("B1").EntireColumn.Inser t
Sheets("SheetName").Range("B1").Value = ""YOUR HEADER"
- That will insert a column to the left of column B - you can adjust it as
needed.
"Jeff" wrote:
Need help creating a macro based upon certain conditions. The Excel
files I will use are in the form of a table database (i.e., first row
has column headings and rows 2 through.... have the related data).
Eventually I will link this Excel file to Microsoft Access.
Question - I would like a macro that will "Find" a particular column
heading (say "Other Sales"). If found, then the macro will end. If it
can't find "Other Sales", the macro will insert a column (location of
new column doesn't matter) and label it "Other Sales", then the macro
would end.
Any help would be appreciated
|