+ Reply to Thread
Results 1 to 5 of 5

copy rows where column data begins with an alpha character

Hybrid View

shaz0503 copy rows where column data... 12-22-2013, 08:49 PM
berlan Re: copy rows where column... 12-22-2013, 09:16 PM
shaz0503 Re: copy rows where column... 12-22-2013, 09:40 PM
berlan Re: copy rows where column... 12-22-2013, 10:00 PM
jindon Re: copy rows where column... 12-22-2013, 10:05 PM
  1. #1
    Forum Contributor
    Join Date
    12-06-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    139

    copy rows where column data begins with an alpha character

    Hi all

    Am trying to set up some macros to 'clean data'.

    I have some in place but am stuck with one that will identify where any address in column "g" that begins with anything other than numeric value copies the entire row to sheet 2...obviously where there is more than one that each copied row is in a new row......

    TIA

    Shaz

  2. #2
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: copy rows where column data begins with an alpha character

    Without fully understanding how this would improve, perhaps this might help?

    Sub main()
    
        Dim ws1 As Worksheet: Set ws1 = ThisWorkbook.Sheets(1)
        Dim ws2 As Worksheet: Set ws2 = ThisWorkbook.Sheets(2)
        Dim c As Range, i As Integer
    
        For Each c In ws1.Range("G1", ws1.Range("G" & Rows.Count).End(xlUp))
            If c.Value Like "[A-Z]*" Or c.Value Like "[a-z]*" Then
                i = i + 1
                c.EntireRow.Copy ws2.Cells(i, 1)
            End If
        Next c
    
    End Sub

  3. #3
    Forum Contributor
    Join Date
    12-06-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    139

    Re: copy rows where column data begins with an alpha character

    Berlan

    Works perfectly - and now I have a base, hopefully I can utilise this further....


    rgds and happy holidays

  4. #4
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: copy rows where column data begins with an alpha character

    You're welcome @shaz0503, and thanks for the rep! Happy holidays!

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

    Re: copy rows where column data begins with an alpha character

    Why use of "Or"?
    change to
            If c.Value Like "[A-Za-z]*" Then

+ 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 rows to new worksheet based on unique first character in column
    By G-N-A in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-12-2013, 12:43 PM
  2. How to copy rows to new worksheet based on unique first character in column
    By G-N-A in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-12-2013, 09:52 AM
  3. How to copy rows to new worksheet based on unique first character in column
    By G-N-A in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-12-2013, 09:52 AM
  4. [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
  5. Copy data from column that begins with data to new sheet
    By Snapdaddy in forum Excel General
    Replies: 1
    Last Post: 04-16-2006, 07:30 PM

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