Consulting

Results 1 to 2 of 2

Thread: How to copy from Column A2 to the last populated Column.

  1. #1

    How to copy from Column A2 to the last populated Column.

    Hi,

    I need some help to create a macro that will copy a range of populated cells.

    The 1st cell will be A2 and the number of rows and columns will be dynamic (will change with each report). The macro will need to find the last row and column.

    Thanks

    BT

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    [VBA]
    Sub CopyAll()
    Dim Rw As Long, Col As Long
    Rw = Cells.Find("*", [a1], , , xlByRows, xlPrevious).Row
    Col = Cells.Find("*", [a1], , , xlByColumns, xlPrevious).Column
    Range(Cells(2, 1), Cells(Rw, Col)).Copy
    End Sub
    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

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