+ Reply to Thread
Results 1 to 6 of 6

Copy an additional row based on another sheet

  1. #1
    Mindie
    Guest

    Copy an additional row based on another sheet

    I have an excel document that contains 3 sheets. The first Sheet supplies me
    with the data to automate the third sheet. Based on what is on the 1st sheet
    and if it is a certain code I want to copy the row on the third sheet that
    corresponds to that data and copy it to the next row on the third sheet. For
    example the first sheet tells me that the code is 01 and based on formulas it
    puts the data on the third sheet. But if the code is 01 I want to duplicate
    that row on the third sheet and copy it down to the next row. Any ideas. I
    tired to do the following but it keeps duplicating the row on the first
    sheet.

    if range("a5")=25 then
    ActiveCell.EntireRow.Copy
    ActiveCell.Offset(1).entirerow.Insert
    Application.CutCopyMode = False

    Thanks Don for that answer it is just not doing what I need it to do.


  2. #2
    bigwheel
    Guest

    RE: Copy an additional row based on another sheet

    I think you need to select the third sheet after you copy the row.

    "Mindie" wrote:

    > I have an excel document that contains 3 sheets. The first Sheet supplies me
    > with the data to automate the third sheet. Based on what is on the 1st sheet
    > and if it is a certain code I want to copy the row on the third sheet that
    > corresponds to that data and copy it to the next row on the third sheet. For
    > example the first sheet tells me that the code is 01 and based on formulas it
    > puts the data on the third sheet. But if the code is 01 I want to duplicate
    > that row on the third sheet and copy it down to the next row. Any ideas. I
    > tired to do the following but it keeps duplicating the row on the first
    > sheet.
    >
    > if range("a5")=25 then
    > ActiveCell.EntireRow.Copy
    > ActiveCell.Offset(1).entirerow.Insert
    > Application.CutCopyMode = False
    >
    > Thanks Don for that answer it is just not doing what I need it to do.
    >


  3. #3
    Mindie
    Guest

    RE: Copy an additional row based on another sheet



    "bigwheel" wrote:

    > I think you need to select the third sheet after you copy the row.
    >
    > "Mindie" wrote:
    >
    > > I have an excel document that contains 3 sheets. The first Sheet supplies me
    > > with the data to automate the third sheet. Based on what is on the 1st sheet
    > > and if it is a certain code I want to copy the row on the third sheet that
    > > corresponds to that data and copy it to the next row on the third sheet. For
    > > example the first sheet tells me that the code is 01 and based on formulas it
    > > puts the data on the third sheet. But if the code is 01 I want to duplicate
    > > that row on the third sheet and copy it down to the next row. Any ideas. I
    > > tired to do the following but it keeps duplicating the row on the first
    > > sheet.
    > >
    > > if range("a5")=25 then
    > > ActiveCell.EntireRow.Copy
    > > ActiveCell.Offset(1).entirerow.Insert
    > > Application.CutCopyMode = False
    > >
    > > Thanks Don for that answer it is just not doing what I need it to do.


    I keep trying to select the third sheet and it keeps giving me an error. I
    tried to do Range("Monday-Date-Codes!A6").select and it is not working. I am
    not much of a VB programmer and I am trying to learn as I go. Here is the
    formula that I have now.
    If Range("Tuesday!A5") = 01 Then
    Range ("Tuesday-Date-Codes!A6").Select
    ActiveCell.EntireRow.Copy
    ActiveCell.Offset(1).EntireRow.Insert
    Application.CutCopyMode = False
    End If

    > >


  4. #4
    bigwheel
    Guest

    RE: Copy an additional row based on another sheet

    Try this:-

    If Range("Tuesday!A5") = 01 Then
    Range ("Tuesday-Date-Codes!A6").Select
    ActiveCell.EntireRow.Copy

    Sheets(3).Select 'insert this new line

    ActiveCell.Offset(1).EntireRow.Insert
    Application.CutCopyMode = False
    End If



  5. #5
    Mindie
    Guest

    RE: Copy an additional row based on another sheet



    "bigwheel" wrote:

    > Try this:-
    >
    > If Range("Tuesday!A5") = 01 Then
    > Range ("Tuesday-Date-Codes!A6").Select
    > ActiveCell.EntireRow.Copy
    >
    > Sheets(3).Select 'insert this new line
    >
    > ActiveCell.Offset(1).EntireRow.Insert
    > Application.CutCopyMode = False
    > End If


    I am still getting the same error. Method 'Range' of object'_Global' failed
    >
    >


  6. #6
    bigwheel
    Guest

    RE: Copy an additional row based on another sheet

    OK try it in this order:-

    If Range("Tuesday!A5") = 1 Then
    ActiveCell.EntireRow.Copy

    Sheets(3).Select 'insert this new line

    Range("TuesdayDateCodes!A6").Select
    ActiveCell.Offset(1).EntireRow.Insert
    Application.CutCopyMode = False
    End If

    and rename your sheet, taking out the hyphens i.e. TuesdayDateCodes

+ 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