Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
inverse of the column function? i.e. input a number, output thecorresponding column text label Brotherharry Excel Worksheet Functions 19 February 14th 09 01:37 AM
Macro- Column Insert lostatlewisu Excel Discussion (Misc queries) 4 August 17th 07 01:44 PM
Macro- Column Insert Toppers Excel Discussion (Misc queries) 1 August 17th 07 01:47 AM
Need Macro to Find Column Heading -- if none, then insert new column Jeff[_43_] Excel Programming 0 December 15th 04 08:08 AM
Macro to insert column Colin Foster[_2_] Excel Programming 4 May 25th 04 04:49 PM


All times are GMT +1. The time now is 06:32 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"