inserting a column to the right
I need to insert a column in two ways.
First, I need to find a column by searching for the text "AZoriginal", then insert a column to the right named "AZ". I will need to add this formula to row 2 of that new column if ( x2 < 0, x2 + 360, x2 ) where x is the column where "AZoriginal" was found. Actually I need to copy the formula down to the bottom row but I have another macro that I think I can use as a template and acomplish that. Second I need to add a new column to the far right end of the data. Then I will insert another formula. Once I see the first and how to add a column to the far right, I should be able to figure out the rest. -- Thank you, Bryan Kelly Time is the medium we use to express out priorities. |
inserting a column to the right
Bryan,
This should work for you: Sub InsertColumnEnterFormula() Dim myCell As Range Set myCell = Cells.Find("AZoriginal") With myCell .Offset(, 1).EntireColumn.Insert .Offset(2 - .Row, 1).FormulaR1C1 = "=IF(RC[-1]<0,RC[-1]+360,RC[-1])" End With End Sub Stan Scott New York City "Bryan Kelly" wrote in message . .. I need to insert a column in two ways. First, I need to find a column by searching for the text "AZoriginal", then insert a column to the right named "AZ". I will need to add this formula to row 2 of that new column if ( x2 < 0, x2 + 360, x2 ) where x is the column where "AZoriginal" was found. Actually I need to copy the formula down to the bottom row but I have another macro that I think I can use as a template and acomplish that. Second I need to add a new column to the far right end of the data. Then I will insert another formula. Once I see the first and how to add a column to the far right, I should be able to figure out the rest. -- Thank you, Bryan Kelly Time is the medium we use to express out priorities. |
inserting a column to the right
Hello Stan,
That has a couple of it items I just added to my list of things to remember. Thank you for your time, Bryan "Stan Scott" wrote in message ... Bryan, This should work for you: Sub InsertColumnEnterFormula() Dim myCell As Range Set myCell = Cells.Find("AZoriginal") With myCell .Offset(, 1).EntireColumn.Insert .Offset(2 - .Row, 1).FormulaR1C1 = "=IF(RC[-1]<0,RC[-1]+360,RC[-1])" End With End Sub <snip |
All times are GMT +1. The time now is 05:26 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com