1

I am brand new to code and have spent hours searching and reading to try and find what I am looking for. I have found this post (Excel VBA - Insert row above specific text and copy formats and formula) that should answer my question but because of my lack of knowledge I am unable to make it completely work for me. I can make the second code work to insert a row based on text but I am unable to determine how to copy the formulas from cells J, O, Z, and AE into the new row.

Can this be done with one code?

Here is the macro:

Sub InsterRowCopyFormatForumula()

' InsertRowCopyFormatFormula Macro '

Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove

Range("A6:B6").Select

Range("J5").Select

Selection.AutoFill Destination:=Range("J5:J6"), Type:=xlFillDefault

Range("J5:J6").Select

Range("O5").Select

Selection.AutoFill Destination:=Range("O5:O6"), Type:=xlFillDefault

Range("O5:O6").Select

Range("Z5").Select

Selection.AutoFill Destination:=Range("Z5:Z6"), Type:=xlFillDefault

Range("Z5:Z6").Select

Range("AE5").Select

Selection.AutoFill Destination:=Range("AE5:AE6"), Type:=xlFillDefault

Range("AE5:AE6").Select

End Sub

Community
  • 1
  • 1
  • For starters, try turning on the macro recorder, and going through the process manually. Then you can view the macro in the editor and see how Excel executed each of your steps. Post the code, and we can look it over to see what you need to do to make it more generally useful. – Hrothgar Mar 01 '17 at 17:18
  • Here is the code: – Mystified User Mar 02 '17 at 15:12

0 Answers0