Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
MWS MWS is offline
external usenet poster
 
Posts: 53
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,316
Default 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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compiling data from several worksheets m Excel Discussion (Misc queries) 3 April 8th 09 03:00 AM
Compiling Data Terry Bennett Excel Worksheet Functions 7 January 10th 06 10:56 PM
Searching for and Pasting Data to a new file Elaine Excel Programming 2 January 10th 06 07:15 PM
Compiling data Jason Sutter Excel Discussion (Misc queries) 0 October 12th 05 08:09 PM
Compiling Excel VBA code increases workbook file size! Romuald[_3_] Excel Programming 6 March 1st 05 08:23 AM


All times are GMT +1. The time now is 12:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"