mathiaspeace
01-21-2015, 11:50 AM
In Excel 2010, I need to add a row below the header that says "text" in each non-blank column. (No columns within the desired range will be blank.) My existing macro inserts a blank line at Row 2, adds the word "text" to cell A2, AutoFills "text" across to the last non-blank column (in this case, AG2), then selects cell A1. I know how to make a row range dynamic, but I need to make the column range dynamic and can't untangle the syntax to do so.
Sub Text_row()
Rows("2:2").Select
Selection.Insert Shift:=x1Down, CopyOrigin:=x1FormatFromLeftOrAbove
Range("A2").Select
ActiveCell.FormulaR1C1 = "text"
Selection.AutoFill Destination:=Range("A2:AG2), Type:=1FillDefault
Range("A1").Select
End Sub
Any help is very welcome, and thank you in advance!
Sub Text_row()
Rows("2:2").Select
Selection.Insert Shift:=x1Down, CopyOrigin:=x1FormatFromLeftOrAbove
Range("A2").Select
ActiveCell.FormulaR1C1 = "text"
Selection.AutoFill Destination:=Range("A2:AG2), Type:=1FillDefault
Range("A1").Select
End Sub
Any help is very welcome, and thank you in advance!