I apologise in advance if this is a glaringly obvious question, but I'm rather inexperienced when using macros.
I have written the following macro to automatically calculate/read a series of values into a new blank row.
Sub Data_Fix_test()
'
' Data_Fix_test Macro
' Inserts formula/reads previous cells
'
'
ActiveCell.FormulaR1C1 = "=R[-1]C"
Range("B6").Select
ActiveCell.FormulaR1C1 = "=R[-1]C &"" Final"""
Range("C6").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-4]C:R[-1]C)"
Range("C6:F6").Select
Selection.FillRight
Range("G6").Select
ActiveCell.FormulaR1C1 = "=R[-1]C"
Range("G6:I6").Select
Selection.FillRight
Rows("6:6").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveSheet.Paste
Application.CutCopyMode = False
Range("C6").Select
End Sub
This works for the cells specified in the code but I need to repeat this process for multiple blank rows throughout the entire data-set i.e. I need to do the same thing 4 rows later, the another 4 rows later etc.
What changes can be made to the code to make this happen. Is it even possible... or do I just have to re-write the code adjusting for the new cell references for every 4 rows?
Many thanks.
P.S. also as a secondary question I have the following macro for inserting a blank row, every 4 rows throughout the entire data set
Sub Insert4_v2()
Dim rng As Range
Set rng = Range("A2")
While rng.Value <> ""
rng.Offset(4).Resize(1).EntireRow.Insert
Set rng = rng.Offset(5)
Wend
End Sub
How would I change this formula to insert a row every 4th row across a specified range of rows rather than across the entire data set?
Bookmarks