Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro - Insert&Label Column, if the labeled column doesn't exist
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
inverse of the column function? i.e. input a number, output thecorresponding column text label | Excel Worksheet Functions | |||
Macro- Column Insert | Excel Discussion (Misc queries) | |||
Macro- Column Insert | Excel Discussion (Misc queries) | |||
Need Macro to Find Column Heading -- if none, then insert new column | Excel Programming | |||
Macro to insert column | Excel Programming |