+ Reply to Thread
Results 1 to 4 of 4

replace numerical data column A, 11K rows! VBA

Hybrid View

  1. #1
    Registered User
    Join Date
    02-08-2009
    Location
    Birmingham, UK
    MS-Off Ver
    Excel 2007
    Posts
    4

    replace numerical data column A, 11K rows! VBA

    Dear forum user,

    I need some help to sort my data in column A which contains a long list of numerical data. To do this manually using copy and paste would be easy, but not viable because of the large amount of data.

    The attached PDF file illustrates the data. I wish to replace each date of dirth entry in column A (one D.O.B. in each cell / row, expressed as YYYYMMDD) with the client identifier number (format 937XXXX) a couple of cells above. And at the same time delete the row containing the client reference (or its contents). The data in column A should retain the same relationship to the data in the other columns (B,C).

    it may require a short piece of VBA code.

    thanks,

    Simon.
    Attached Files Attached Files
    Last edited by brumylad; 02-08-2009 at 06:21 PM.

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: replace numerical data column A, 11K rows! VBA

    Try this macro.

    Sub Test()
    LastRow = Cells(Cells.Rows.Count, 1).End(xlUp).Row
    EndOfBlock = LastRow
    For N = LastRow To 1 Step -1
        If Left(Cells(N, 1), 3) = "937" Then
            For M = N + 1 To EndOfBlock
                If Cells(M, 1) <> "" Then
                    Cells(M, 1) = Cells(N, 1)
                End If
            Next M
            EndOfBlock = N - 1
            Rows(N).Delete
        End If
    Next N
    End Sub
    Martin

  3. #3
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: replace numerical data column A, 11K rows! VBA

    For some reason the counter is no displaying properly. Trying again.

    Sub Test()
    LastRow = Cells(Cells.Rows.Count, 1).End(xlUp).Row
    EndOfBlock = LastRow
    For N = LastRow To 1 Step -1
        If Left(Cells(N, 1), 3) = "937" Then
            For M = N + 1 To EndOfBlock
                If Cells(M, 1) <> "" Then
                    Cells(M, 1) = Cells(N, 1)
                End If
            Next M
            EndOfBlock = N - 1
            Rows(N).Delete
        End If
    Next N
    End Sub

  4. #4
    Registered User
    Join Date
    02-08-2009
    Location
    Birmingham, UK
    MS-Off Ver
    Excel 2007
    Posts
    4

    Thumbs up My sincere thanks.

    Thank you Martin,

    I'm a complete novice with VBA.

    That is a superb piece of code in my opinion, I've poured over my VBA for dummies book for the past 48 hours and I couldn't figure how to do this.

    You've added days /weeks to my life and made possible my project that might well have stalled because of this hurdle.

    My sincere thanks

    Simon

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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