Results 1 to 2 of 2

Thread: Simple vba, big problem for beginner

  1. #1

    Simple vba, big problem for beginner



    Register for a FREE account, and/
    or Log in to avoid these ads!

    Hi, I have no idea how to do a VBA, but got one online which nearly does the job. Basically i have 2000 columns for 4000 rows, so manual copy and paste will take days. I have a blank column between each which i need a basic formula inserted. EG in cell D4 i need (C5-C4)/C4. The macro i have does this but it does not update the formula for D6 where i will need (C6-C5)/C5 and so on so forth instead it copies (C5-C4)/C4 into all the blank cells i need the formulas in? Can anyone help me please?
    This is the macro i am running at the moment:

    Sub fcopy()
    Dim r, c As Integer
    For r = 4 To 55
    For c = 4 To 20 Step 2
    Cells(r, c).Formula = "=(c5-c4)/c4"
    Next
    Next
    End Sub



    Thanks for any replies!

  2. #2
    Code:
    Sub fcopy()
    Dim c As Long
        
        Application.ScreenUpdating = False
        Application.Calculation = xlCalculationManual
        
        For c = 4 To 20 Step 2
            Cells(4, c).Resize(52).FormulaR1C1 = "=(R[+1]C[-1]-RC[-1])/RC[-1]"
        Next
        
        Application.ScreenUpdating = True
        Application.Calculation = xlCalculationAutomatic
    End Sub

Tags for this Thread

Posting Permissions

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