![]() |
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 |
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 |
All times are GMT +1. The time now is 12:02 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com