Results 1 to 3 of 3
  1. #1
    Join Date
    May 2005
    Provided Answers: 1

    Question Unanswered: VBA Help required, do not know where to start

    I need your help, and to be honest not sure how to approach it, I receive a file from an external source, and the layout is preset.

    But for me to reference each line by account, I need the account number copying and pasted into the relevant, blank lines below, until the code finds the next account number in the column and repeats the process copy and paste down until next available account number

    In the attached file you will see that there is an account number in D2 (890089), I need the code to copy this account number down from D2 – D10, then pick the next account number in D11 (970096) copy and paste down to D22, the ranges above are examples, and will differ from file to file, I need the process to repeat until the end of the file

    If it’s possible I would like the result to be as per the example account number 100096 from D23 – D27

    Hope this makes sense

    Attached Files Attached Files

  2. #2
    Join Date
    Apr 2004
    Derbyshire, UK
    Provided Answers: 2
    Try this
    Sub CopyAccuntNos()
        Dim LastRow As Integer
        Dim i As Long
        Dim AccNo As String
        Cells(1, 1).Select
        LastRow = ActiveCell.SpecialCells(xlLastCell).Row
        For i = 1 To LastRow
            If AccNo <> "" And Cells(i, 4) = "" Then
                Cells(i, 4) = AccNo
            ElseIf Cells(i, 4) <> "" Then
                AccNo = Cells(i, 4)
            End If
        Next i
    End Sub


  3. #3
    Join Date
    May 2005
    Provided Answers: 1
    Hi MTB

    Thanks for the reply & sorry for the delay in getting back to you

    Code works perfectly, Thanks for your help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts