View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Find column and then insert column

The easiest method is to use find

with workbooks("book1.xls").sheets("Sheet1")
set c = Rows("1:1").find(what:="Original",lookin:=xlValues )
if not c is nothing then
'enter code if found
else
set c = Rows("1:1").find(what:="total",lookin:=xlValues)
if not c is nothing then
c.entirecolumn.insert
c.value = "Original"
end if
end if
end with


"PAG" wrote:

Hi,

I am new to creating macros in Excel.

Can someone please help me add to a macro I currently use.

All I want to do is search an excel workbook for a particular
column(Original Notional) and have the macro add that column if it isn't
alreay there. There normally is the following columns of X-Date, Payment
Date, Fund, Sub-Portfolio, Cusip, Broker, Security Name, Notional Amt , and
Total Payment. Sometimes the workbook has the Original Notional and sometimes
it doesn't. If the Original Notional column is there it would before the
Total Payment column.

Can anyone please help me?


Thank You

Peter