Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default adding columns

Assuming that you are in the far right column . . .

NewColumn = LastColumn + 1
ActiveCell.Offset(0, NewColumn).Select

This code will move you "LastColumn + 1" from the active cell.
If you are not in the far right column, then you could use the following . .
..

MyColumn = ActiveCell.Column
NewColumn = LastColumn - MyColumn + 1
ActiveCell.Offset(0, NewColumn).Select

"Bryan" wrote in message
.. .
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




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
Adding Two Columns Gr8 Dane[_2_] Excel Worksheet Functions 2 February 10th 09 09:47 AM
adding columns Munro New Users to Excel 3 January 30th 09 10:19 PM
I need help adding columns Tash New Users to Excel 1 January 20th 09 09:31 PM
Adding columns BJS Excel Discussion (Misc queries) 4 December 18th 08 06:49 PM
Adding Columns, Then deleting old columns May Excel Discussion (Misc queries) 4 October 30th 08 04:44 PM


All times are GMT +1. The time now is 07:29 AM.

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"