+ Reply to Thread
Results 1 to 15 of 15

copying rows, while keeping formulas on orginal

  1. #1
    Forum Contributor
    Join Date
    07-08-2015
    Location
    Indiana
    MS-Off Ver
    Excel 2007
    Posts
    128

    Question copying rows, while keeping formulas on orginal

    Hi all and thanks in advance to all

    I am slowing making headway. But I am stuck. I am trying to copy all of a row, to another sheet, which is working fine.

    But, I want to preserve the formulas from the original sheet after I clear that data out. I am using a copy command, and it works well, b ut leave the original data behind.

    So I tried cut-- obviously, it took everything out.

    I have been experimenting with the clear command, and using this line of code

    Sheets("Sheet2").Range("2:2").Clear

    After I have copied the data, I am clearing the row. Is there another comman d, ,or an add on that will leave the formulas behind and clear out teh row?

    Thanks again..

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: copying rows, while keeping formulas on orginal

    Hi Scott

    You could try this.
    Please Login or Register  to view this content.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Forum Contributor
    Join Date
    07-08-2015
    Location
    Indiana
    MS-Off Ver
    Excel 2007
    Posts
    128

    Re: copying rows, while keeping formulas on orginal

    John.

    Thanks. 2 follow up questions:

    1) The code leaves the formulas, but removes the drop down list from column B. Anyway to preserve that?

    2) Is there a way that this will work for all rows of data? It is variable depending on the day as to how many rows I will have. I have attempted to put in m y counter variable where the "2:2" are to go through all rows, but it only executed on a row when I specify an constant number (ie rown 2, or 3, or 4....)

    Thanks again

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: copying rows, while keeping formulas on orginal

    Hi Scott

    If you'll post a sample of your Data...with existing Code and of the same structure as Actual Data, I'll look at it.

    Edit: for this issue
    The code leaves the formulas, but removes the drop down list from column B. Anyway to preserve that?
    Try this (untested).
    Please Login or Register  to view this content.
    Last edited by jaslake; 12-29-2015 at 03:18 PM.

  5. #5
    Forum Contributor
    Join Date
    07-08-2015
    Location
    Indiana
    MS-Off Ver
    Excel 2007
    Posts
    128

    Re: copying rows, while keeping formulas on orginal

    John

    Thanks so much for you assistance. The code you gave me I pasted into each case section. I realize they all say "2:2". I may have 10 rows on monday, 3 rows tuesday, 25 rows wednesday of data that I will input, and subsequently copy to the other sheets.

    Here is my code:

    Sub Macro2()
    Dim lr As Long, lr2 As Long, lr3 As Long, lr4 As Long, r As Long

    lr = Sheets("Sheet2").Cells(Rows.Count, "A").End(xlUp).Row
    lr2 = Sheets("RV2032").Cells(Rows.Count, "A").End(xlUp).Row
    lr3 = Sheets("0042298-02").Cells(Rows.Count, "A").End(xlUp).Row
    lr4 = Sheets("41352").Cells(Rows.Count, "A").End(xlUp).Row
    For r = 2 To lr
    Select Case Range("B" & r).Value
    Case Is = "RV2032"
    Range(Cells(r, 1), Cells(r, 10)).Copy Destination:=Sheets("RV2032").Range("A" & lr2 + 1)
    lr2 = Sheets("RV2032").Cells(Rows.Count, "A").End(xlUp).Row
    Sheets("Sheet2").Range("2:2").SpecialCells(xlCellTypeConstants).ClearContents
    Case Is = "0042298-02"
    Range(Cells(r, 1), Cells(r, 10)).Copy Destination:=Sheets("0042298-02").Range("A" & lr3 + 1)
    lr3 = Sheets("0042298-02").Cells(Rows.Count, "A").End(xlUp).Row
    Sheets("Sheet2").Range("2:2").SpecialCells(xlCellTypeConstants).ClearContents
    Case Is = "41352"
    Range(Cells(r, 1), Cells(r, 10)).Copy Destination:=Sheets("41352").Range("A" & lr4 + 1)
    lr4 = Sheets("41352").Cells(Rows.Count, "A").End(xlUp).Row
    Sheets("Sheet2").Range("2:2").SpecialCells(xlCellTypeConstants).ClearContents
    End Select

    Next r
    End Sub

    My data looks something like this:

    a b c d e
    date part number part name customer quantity


    Thanks again

    Scott

  6. #6
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: copying rows, while keeping formulas on orginal

    Hi Scott

    Please use Code Tags around any Code you post to the Forum.

    Please attach a Workbook that includes existing Code and a representative sample of your Data.

  7. #7
    Forum Contributor
    Join Date
    07-08-2015
    Location
    Indiana
    MS-Off Ver
    Excel 2007
    Posts
    128

    Re: copying rows, while keeping formulas on orginal

    Sorry. New to this forum:

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by alansidman; 12-29-2015 at 06:36 PM.

  8. #8
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: copying rows, while keeping formulas on orginal

    Hi Scott

    Dropdown list in Column B appears to be missing from the Worksheet.

  9. #9
    Forum Contributor
    Join Date
    07-08-2015
    Location
    Indiana
    MS-Off Ver
    Excel 2007
    Posts
    128

    Re: copying rows, while keeping formulas on orginal

    Try now. Each time I have been running it and trying new code, it takes the drop list out.
    Attached Files Attached Files

  10. #10
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: copying rows, while keeping formulas on orginal

    Nope, still no drop down. What's the Source of the Drop Down List?

  11. #11
    Forum Contributor
    Join Date
    07-08-2015
    Location
    Indiana
    MS-Off Ver
    Excel 2007
    Posts
    128

    Re: copying rows, while keeping formulas on orginal

    The source is column A off sheet1. I just looked on the copy I sent you, and its down column B. Dose it not transfer when uploading?

  12. #12
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: copying rows, while keeping formulas on orginal

    Hi Scott

    This Code in the attached does not delete the Dropdown in Column B; it DOES clear all processed Rows of Data but not Formulas.

    I can't, for the life of me, figure out what it is you're doing...why only 3 part numbers?
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by jaslake; 12-29-2015 at 04:59 PM.

  13. #13
    Forum Contributor
    Join Date
    07-08-2015
    Location
    Indiana
    MS-Off Ver
    Excel 2007
    Posts
    128

    Re: copying rows, while keeping formulas on orginal

    John

    thank you so much!!

    I am using 3 part numbers to figure out what I need to do for our company. We currently have 32 part numbers that we use, and we will be growing to over 100 by mid 2016. In my mind, I wanted to understand and get 3 working, then expand it to the full lilst of part numbers.

    You have been such a great help.

    Thanks again

    Scott

  14. #14
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: copying rows, while keeping formulas on orginal

    Hi Scott

    When you get to this point you'll want to be using a different approach than Select Case...Filtering perhaps...but you'll figure it out. Best of luck in your quest.
    In my mind, I wanted to understand and get 3 working, then expand it to the full list of part numbers.

  15. #15
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: copying rows, while keeping formulas on orginal

    You're welcome...glad I could help.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Copying Formulas Between Worksheets While Keeping Reference to Original Worksheet
    By PandaBear2014 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-04-2014, 06:32 PM
  2. Copying over cells from one sheet to the next and deleting orginal cell source
    By masond3 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-27-2013, 07:54 AM
  3. Copying Values but keeping rows that have formulas in them
    By amartino44 in forum Excel General
    Replies: 1
    Last Post: 01-01-2013, 04:44 PM
  4. Replies: 10
    Last Post: 04-21-2006, 10:15 PM
  5. Replies: 3
    Last Post: 04-21-2006, 02:24 PM
  6. Replies: 3
    Last Post: 03-07-2006, 03:30 PM
  7. adding new rows and keeping the same formulas
    By [email protected] in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-07-2006, 01:15 PM
  8. Keeping formulas but not data's when copying workbook?
    By Samshun in forum Excel General
    Replies: 1
    Last Post: 01-14-2005, 09:06 AM

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