inserting a column to the right

B

Bryan Kelly

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.
 
S

Stan Scott

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
 
B

Bryan Kelly

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 said:
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>
 
Top