Results 1 to 3 of 3

Thread: [RESOLVED] how to copy some formulas to selected rows

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2021
    Posts
    9

    Resolved [RESOLVED] how to copy some formulas to selected rows

    Hi,

    We are adding some formula manualy but now we have large data around 1200 and want help to do it with vba or code

    We are putting the Text Max in N2 and formula in Book1.zipO2:Q2 (All formula are different)
    and after that We are putting the Text Min in N3 and formula O3:Q3 (All formula are different)

    All the above work we are doing in N8, N14 and all other.

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: how to copy some formulas to selected rows

    you can test this to see if it works how you want
    Code:
    lr = Cells(Rows.Count, 1).End(xlUp).Row
    For rw = 2 To lr Step 6
        With Cells(rw, 14)
            .Value = "Max"
            .Offset(1) = "Min"
            .Offset(, 1).Formula = "=Max(F" & rw & ":F" & rw + 4 & ")"
            .Offset(1, 1).Formula = "=Min(F" & rw & ":F" & rw + 4 & ")"
        End With
    Next
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2021
    Posts
    9

    Re: how to copy some formulas to selected rows

    thank you very much westconn1, your code solved my problem

Posting Permissions

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



Click Here to Expand Forum to Full Width