+ Reply to Thread
Results 1 to 3 of 3

Copy formula down to last row.

  1. #1
    Registered User
    Join Date
    07-14-2010
    Location
    Houston, TX
    MS-Off Ver
    Excel 2003
    Posts
    20

    Copy formula down to last row.

    I'm working with a worksheet that has several columns (A - U) and I would like to change the data in column F using an "IF" statement. Example if the data in cell F1 equals 1 make it "Buy" if not make it "Sell". And copy this down as long as there is data. The macro that I have works if I have a large number of rows but if it's a small number of rows for some reason it is still copying the data down the entire column F. I would like the macro to be able to change with the data which is why I'm looking at how to have it copy my formula to the last row and copy and paste it over to F. fyi I'm using Column V to do my if statement and copying it over to F. Here is my macro. Any ideas?

    Range("V1").Select
    ActiveCell.FormulaR1C1 = "=IF(RC[-16]=1,""Buy"",""Sell"")"
    Range("V1").Select
    Selection.Copy
    Columns("V:V").Select
    Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
    SkipBlanks:=False, Transpose:=False
    Application.CutCopyMode = False
    Selection.Copy
    Columns("F:F").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Range("F1").Select
    Application.CutCopyMode = False
    ActiveCell.FormulaR1C1 = "Trade Type"
    Columns("V:V").Select
    Selection.Delete Shift:=xlToLeft
    Range("V2").Select
    End Sub

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: Copy formula down to last row.

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

  3. #3
    Registered User
    Join Date
    07-14-2010
    Location
    Houston, TX
    MS-Off Ver
    Excel 2003
    Posts
    20

    Re: Copy formula down to last row.

    I'm working with a worksheet that has several columns (A - U) and I would like to change the data in column F using an "IF" statement. Example if the data in cell F1 equals 1 make it "Buy" if not make it "Sell". And copy this down as long as there is data. The macro that I have works if I have a large number of rows but if it's a small number of rows for some reason it is still copying the data down the entire column F. I would like the macro to be able to change with the data which is why I'm looking at how to have it copy my formula to the last row and copy and paste it over to F. fyi I'm using Column V to do my if statement and copying it over to F. Here is my macro. Any ideas?

    Please Login or Register  to view this content.

+ Reply to Thread

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