Results 1 to 2 of 2

Insert three formulas one in each column paste values

Threaded View

marreco Insert three formulas one in... 10-27-2012, 11:50 AM
jeffreybrown Re: Insert three formulas one... 10-27-2012, 12:10 PM
  1. #1
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    1,862

    Insert three formulas one in each column paste values

    Hi.
    I need to put a formula in each row and then drag down, and paste values​​.

    tried the code below, but it was cool.
    Sub InputFormula()
    Dim lr As Range
        'cell I1=If(J2<>"""",H2,"""")
        'celula J1=If(Countif(B:B,H2)>0,Countif(B:B,H2)
        'celula K1=If(Sumif(B:B,H2,C:C)>0,Sumif(B:B,H2,C:C),"""")
        
        With Sheets("Result")
        Set lr = .Cells(.Rows.Count, "H").End(xlUp).Offset(, 1)
        With .Range("I2", lr)
            .Formula = "=If(J2<>"""",H2,"""")"
            .Value = .Value 'if you want to convert the formulae to hard values.
        End With
        Set lr = .Cells(.Rows.Count, "H").End(xlUp).Offset(, 2)
        With .Range("J2", lr)
            .Formula = "=If(Countif(B:B,H2)>0,Countif(B:B,H2),"""")"
            .Value = .Value
        End With
        
        Set lr = .Cells(.Rows.Count, "H").End(xlUp).Offset(, 3)
        With .Range("K2", lr)
            .Formula = "=If(Sumif(B:B,H2,C:C)>0,Sumif(B:B,H2,C:C),"""")"
            .Value = .Value
        End With
        End With
    
    End Sub
    if someone can improve this code, I'd be grateful!
    Thank you!!!
    Last edited by marreco; 10-27-2012 at 12:38 PM.
    "No xadrez nem sempre a menor dist?ncia entre dois pontos ? uma linha reta" G. Kasparov.

    If your problem is solved, please say so clearly, and mark your thread as Solved: Click the Edit button on your first post in the thread, Click Go Advanced, select b from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Edit button will not appear -- ask a moderator to mark it.

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