+ Reply to Thread
Results 1 to 4 of 4

VBA to move data to another worksheet based on the value of a cell

Hybrid View

  1. #1
    Registered User
    Join Date
    07-12-2011
    Location
    Houston, Texas
    MS-Off Ver
    Excel 2010
    Posts
    8

    VBA to move data to another worksheet based on the value of a cell

    Hello, I and new to VBA and have tried for a few hours to figure this one out with no success, Please help!

    I'm trying to enter a row of data and then generate duplicate rows with the same data based on the Quantity value on "sheet2".

    the numbers in "A2" are sequential. so it should grab the next available number and them when running the macro duplicate the line the number of times listed in the qty column.

    Example

    Serial # PO # IR# Part # Description Heat # Qty Date By
    S123456 P654321 I58742 A345678 Bike zGrips 3 =Now() =username


    this would output into this on "Sheet2"

    Serial # PO # IR# Part # Description Heat # Qty Date By
    S123456 P654321 I58742 A345678 Bike zGrips 3 3/13/15 Ryan O
    S123457 P654321 I58742 A345678 Bike zGrips 3 3/13/15 Ryan O
    S123458 P654321 I58742 A345678 Bike zGrips 3 3/13/15 Ryan O

    (Save) then it would be ready for the next entry

    Serial # PO # IR# Part # Description Heat # Qty Date By
    S123459

    all help is much appreciated!!

  2. #2
    Registered User
    Join Date
    07-12-2011
    Location
    Houston, Texas
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: VBA to move data to another worksheet based on the value of a cell

    Sample file attached might explain what I'm trying to do better.
    Attached Files Attached Files

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: VBA to move data to another worksheet based on the value of a cell

    My guess...
    Sub test()
        Dim myRows As Long
        myRows = Sheets("sheet1").Range("g2").Value
        Sheets("sheet1").Cells(1).CurrentRegion.Rows(2).Copy
        With Sheets("sheet2").Range("a" & Rows.Count).End(xlUp)(2).Resize(myRows)
            .PasteSpecial xlPasteValues
            .Cells(1).AutoFill .Cells(1).Resize(.Rows.Count)
            .Columns("i").Value = Environ("username")
        End With
    End Sub

  4. #4
    Registered User
    Join Date
    07-12-2011
    Location
    Houston, Texas
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: VBA to move data to another worksheet based on the value of a cell

    Jindon, Thanks! That works well.

    1. I want to avoid accidental duplication, is their a way to locate the last serial number in sheet 2 row "A" and automatically start with that number +1?

    2. after submit auto save.

    3. lastly can sheet 2 highlight the cells entered into sheet 2 and select them and prompt for printing?

+ 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] Move row to another worksheet based on cell value
    By RTFAchllesi in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-03-2014, 11:22 PM
  2. Move data to worksheet based on values
    By rolo_celticfc in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 10-04-2014, 04:14 PM
  3. Replies: 0
    Last Post: 08-11-2014, 02:38 PM
  4. Need to move data that matches criteria in cell and move to new worksheet
    By panagle in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-27-2013, 09:23 AM
  5. Move Row To Another Worksheet Based On A Cell Value
    By klk300 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 11-28-2012, 10:58 AM

Tags for this Thread

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