+ Reply to Thread
Results 1 to 2 of 2

Pasting/Compiling Data To The End Of A File

  1. #1
    MWS
    Guest

    Pasting/Compiling Data To The End Of A File

    Hello, I have written a macro to import data into an excel file, but
    currently have the data always being copied into a designated cell - "A1".
    What I actually need to do is have all the information continually compile.

    For instance, there may be 10 items during the first import, which would
    value rows 1 through 10. A subsequent import may then have 15 items and then
    the data should go to the next available row, row 11.

    Can someone suggest code to accomplish this?

    Any and All Help Will Be Appreciated

  2. #2
    Kevin B
    Guest

    RE: Pasting/Compiling Data To The End Of A File


    This is example assumes that the data starts in A1 and there aren't any
    blank lines in the data.

    Sub NextRow()

    Dim wb As Workbook
    Dim ws As Worksheet
    Dim l As Long
    Set wb = ActiveWorkbook
    Set ws = wb.Worksheets("Sheet1")
    Dim r As Range

    'Activate Sheet1 in the current workbook and select cell A1
    ws.Activate
    Range("A1").Select

    'Select the current contiguous region and name it
    Selection.CurrentRegion.Select
    Selection.Name = "CurrentData"

    'count the number of rows in the named range
    l = Range("CurrentData").Rows.Count
    'Select the next available cell in column by
    'adding 1 to the total count of row in the
    'named range
    Cells(l + 1, 1).Select

    Set r = Nothing
    Set ws = Nothing
    Set wb = Nothing

    End Sub

    --
    Kevin Backmann


    "MWS" wrote:

    > Hello, I have written a macro to import data into an excel file, but
    > currently have the data always being copied into a designated cell - "A1".
    > What I actually need to do is have all the information continually compile.
    >
    > For instance, there may be 10 items during the first import, which would
    > value rows 1 through 10. A subsequent import may then have 15 items and then
    > the data should go to the next available row, row 11.
    >
    > Can someone suggest code to accomplish this?
    >
    > Any and All Help Will Be Appreciated


+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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