Thread: adding columns
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bryan[_12_] Bryan[_12_] is offline
external usenet poster
 
Posts: 7
Default adding columns

I posted this in the charting forum but have received no replies. I am
doing this with a macro so maybe it should have been here in the programming
forum.

I need to add some columns to the right edge of the data page so I can do
some charting. From this forum I got the following line that will determine
the last column.
LastColumn = ActiveSheet.Cells.Find(what:="*", SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column

After running this macro LastColum might have the value of 7 (or 8 or 9,
etc). Knowing this, how do I go to the eighth column and start adding in
some data. Here is some pseudo code of what I need to do.

LastColumn = ActiveSheet.Cells.Find(what:="*", SearchOrder:=xlByColumns,
SearchDirection:=xlPrevious).Column
NewColumn = <LastColumn + 1
ColumnA = <find_column_with_title_x
ColumnB = find_column_with_title_y

NewColumn.row_2.FormulaR1C1 = ColumnA.row2 - ColumnB.row2
(In english: set the cell in row 2 of the new column equal to the value that
is in Column A row 2 minus Column B row 2. I cannot guarentee that the data
will be in any given column but I can guarentee the column header will be
known.)

Is this clear enough to solicit an answer?
Thank you,
Bryan