Results 1 to 4 of 4

Problem adjusting macro for different cell refernces

Threaded View

  1. #1
    Registered User
    Join Date
    01-30-2013
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    2

    Problem adjusting macro for different cell refernces

    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?
    Last edited by toph1903; 01-30-2013 at 08:38 AM. Reason: Inaccurate title

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1