+ Reply to Thread
Results 1 to 6 of 6

Searching Values that Follow a Specific Format and Copy Rows to a New Sheet

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    06-29-2012
    Location
    Calgary CA
    MS-Off Ver
    Excel 2010
    Posts
    117

    Searching Values that Follow a Specific Format and Copy Rows to a New Sheet

    Hello VBA Gurus:

    Please write a VBA code that do the following tasks:

    Pseudo Code:

    *This code applies to Quote Summary sheet ONLY.

    1, Create a new sheet on the next available tab and name it "Quote Summary(DHC-8)".

    2, Copy the first row of "Quote Summary" to the sheet "Quote Summary(DHC-8)".

    3, Start from Row 2, if cell A2 has the format " 8xxxxxxx-" (Before "-" : all number, starting at 8, 8 digits ; After "-" : number and letter , can be any length), then copy row 2 to the next available row on the sheet "Quote Summary(DHC-8)".

    4, Repeat until the end of the sheet "Quote Summary"


    Sample File
    Process Sample 7-Get Dash8 Parts.xlsm


    Thank you and I am looking forward to your response,

    Chris
    Last edited by aviatecar; 11-17-2014 at 11:48 AM.

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Searching Values that Follow a Specific Format and Copy Rows to a New Sheet

    Maybe:

    Sub aviatecar()
    Dim ws As Worksheet
    Dim i As Long
    Set ws = Sheets("Quote Summary")
    Sheets.Add.Name = "Quote Summary(DHC-8)"
    Sheets("Quote Summary(DHC-8)").Rows(1).Value = ws.Rows(1).Value
    With ws
        For i = 2 To .Range("A" & Rows.Count).End(3).Row
            If Left(.Range("A" & i), 1) = 8 And Right(Left(.Range("A" & i), 8), 1) = "-" Then
                .Rows(i).Copy Sheets("Quote Summary(DHC-8)").Range("A" & Rows.Count).End(3)(2)
            End If
        Next i
    End With
    End Sub

  3. #3
    Forum Contributor
    Join Date
    06-29-2012
    Location
    Calgary CA
    MS-Off Ver
    Excel 2010
    Posts
    117

    Re: Searching Values that Follow a Specific Format and Copy Rows to a New Sheet

    Hello John:

    Thank you for your response.

    But this code does not do what I want it to do.

    -The code created a new sheet on the left side of the "Quote Summary" sheet but I want the new sheet to be at the end of the sheet tabs.

    -This code does not return the data with the format specified below.

    if cell A2 has the format " 8xxxxxxx-"
    (Before "-" : 1) all number; 2) starting at 8; 3) 8 digits ; After "-" : no limitation),
    then copy row 2 to the next available row on the sheet "Quote Summary(DHC-8)".


    Thank you and I am looking forward to your reply,

    Chris

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Searching Values that Follow a Specific Format and Copy Rows to a New Sheet

    Try:

    Sub aviatecar()
    Dim ws As Worksheet
    Dim i As Long
    Set ws = Sheets("Quote Summary")
    Sheets.Add.Name = "Quote Summary(DHC-8)"
    Sheets("Quote Summary(DHC-8)").Rows(1).Value = ws.Rows(1).Value
    Sheets("Quote Summary(DHC-8)").Move After:=Sheets(Sheets.Count)
    With ws
        For i = 2 To .Range("A" & Rows.Count).End(3).Row
            If Right(Left(.Range("A" & i), 9), 1) = "-" Then
            If IsNumeric(Left(.Range("A" & i), 8)) Then
            If Left(.Range("A" & i), 1) = 8 Then
                .Rows(i).Copy Sheets("Quote Summary(DHC-8)").Range("A" & Rows.Count).End(3)(2)
            End If
            End If
            End If
        Next i
    End With
    End Sub

  5. #5
    Forum Contributor
    Join Date
    06-29-2012
    Location
    Calgary CA
    MS-Off Ver
    Excel 2010
    Posts
    117

    Re: Searching Values that Follow a Specific Format and Copy Rows to a New Sheet

    Works Like a Charm!

    Thank you John!

    Chris

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Searching Values that Follow a Specific Format and Copy Rows to a New Sheet

    You're welcome, Chris. Thanks for the feedback.

+ 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] Copy rows with specific text in specific column into specific sheet
    By Valemaar in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 08-22-2014, 03:23 PM
  2. Replies: 3
    Last Post: 08-06-2014, 07:57 AM
  3. Replies: 1
    Last Post: 05-26-2014, 09:22 AM
  4. Copy rows with values in specific column to first empty row in specified sheet
    By scaffdog845 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-20-2013, 08:29 PM
  5. Replies: 0
    Last Post: 09-17-2012, 11:10 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