Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Adding Two Columns | Excel Worksheet Functions | |||
adding columns | New Users to Excel | |||
I need help adding columns | New Users to Excel | |||
Adding columns | Excel Discussion (Misc queries) | |||
Adding Columns, Then deleting old columns | Excel Discussion (Misc queries) |