Results 1 to 7 of 7

Thread: how to copy some formulas to selected rows NEW

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2021
    Posts
    9

    how to copy some formulas to selected rows NEW

    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 O2: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.

    Get the below Code from westconn1
    HTML 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
    want to add some more formula in next column
    In Column P2 =Roundup(O2)
    In Column P3 =ROUNDDOWN(O3)

    In Column Q2 =P2+0.40
    In Column Q3 =P3+0.40
    Attached Files Attached Files

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

    Re: how to copy some formulas to selected rows NEW

    did you have a go yourself? workout the difference in offset and the formula string would be quite similar
    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 NEW

    as per your instructions, we have tried but not find the solution

    we know some about offset but unable to find
    how to convert
    = "=Min(F" & rw & ":F" & rw + 4 & ")" to in P2 value =ROUNDUP(O2) and Q2 Value =P2+0.2

    help pls

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

    Re: how to copy some formulas to selected rows NEW

    for each offset, try like
    Code:
    .formula = "=roundup(O" & rw & ")"
    'and
    .formula = "=P" & rw & "+ .02"
    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

  5. #5

    Thread Starter
    New Member
    Join Date
    Jan 2021
    Posts
    9

    Re: how to copy some formulas to selected rows NEW

    This is not working
    .formula = "=roundup(O" & rw & ")"

    This is working
    .formula = "=P" & rw & "+ .02"

  6. #6

    Thread Starter
    New Member
    Join Date
    Jan 2021
    Posts
    9

    Re: how to copy some formulas to selected rows NEW

    = "=ROUNDUP(F" & rw & ",0)"

    the above formula is working, after making some changes and test, find the solution

    Thanks westconn1

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

    Re: how to copy some formulas to selected rows NEW

    well done
    i just did the formula as you posted, i should have checked the parameters for the function
    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

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