+ Reply to Thread
Results 1 to 3 of 3

Copy Entire row if value in column D begins with "21"

Hybrid View

  1. #1
    Registered User
    Join Date
    07-29-2013
    Location
    USA, USA
    MS-Off Ver
    Excel 2010
    Posts
    4

    Copy Entire row if value in column D begins with "21"

    Thanks in advance for any assistance you may be able to provide, below is the problem statement:

    Copy Entire row if value in column D begins with "21"

    1) Copy from a tab titled "BOC"
    2)Copy to a tab titled "BOC 21"

    Also if possible: If the value in column D begins with "22", "23", or "24" copy the row into a tab labeled "BOCs 22, 23, 24

    If the value in column D begins wih "26" copy the entire row in a tab titled "BOC 26"

    Again the source of the data is in tab titled "BOC", once the data has beeen copied from BOC is it possible to have the macro delete the row?

    Please keep in mind that the tabs already contain static data I would like the copied rows to be appended after the last row of static data in each tab. See attached sample data for example. Thanks Again!
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Copy Entire row if value in column D begins with "21"

    Sub macro_1()
    Dim count
    count = 2
    Do Until Sheets("BOC").Range("A" & count) = ""
        If Strings.Left(Sheets("BOC").Range("D" & count), 2) = "21" Then
            Sheets("BOC").Rows(count).Copy Sheets("BOC 21").Rows(Sheets("BOC 21").Range("A" & Rows.count).End(xlUp).Row + 1)
            Rows(count).Delete
        ElseIf Strings.Left(Sheets("BOC").Range("D" & count), 2) = "22" Or _
         Strings.Left(Sheets("BOC").Range("D" & count), 2) = "23" Or _
         Strings.Left(Sheets("BOC").Range("D" & count), 2) = "24" Then
            Sheets("BOC").Rows(count).Copy Sheets("BOC 22, 23, 24").Rows(Sheets("BBOC 22, 23, 24").Range("A" & Rows.count).End(xlUp).Row + 1)
            Rows(count).Delete
        ElseIf Strings.Left(Sheets("BOC").Range("D" & count), 2) = "25" Then
            Sheets("BOC").Rows(count).Copy Sheets("BOC 25").Rows(Sheets("BOC 25").Range("A" & Rows.count).End(xlUp).Row + 1)
            Rows(count).Delete
        ElseIf Strings.Left(Sheets("BOC").Range("D" & count), 2) = "26" Then
            Sheets("BOC").Rows(count).Copy Sheets("BOC 26").Rows(Sheets("BOC 26").Range("A" & Rows.count).End(xlUp).Row + 1)
            Rows(count).Delete
        Else
            count = count + 1
        End If
    Loop
    End Sub

  3. #3
    Registered User
    Join Date
    07-29-2013
    Location
    USA, USA
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Copy Entire row if value in column D begins with "21"

    Thanks yudlugar! Works like a charm, Thank you! The only change I made was retitling "BBOC 22, 23, 24" to "BOCs 22, 23, 24" everything else was perfect!

+ 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] How to copy all character till first space which begins with "RXO" data
    By nur2544 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-06-2013, 07:35 AM
  2. copy entire row to new worksheet if column 2 = "X"
    By steveb34 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-13-2012, 01:00 AM
  3. Applying a "Left" formula to an entire column with heading "ValueCol"
    By aad401 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-12-2012, 04:14 PM
  4. Backup to specific folder if workbook names begins with "NSR" or "MAC"
    By GregR in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-05-2005, 08:06 PM

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