Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 163
Default MACRO HELP CONTINUED


Below is the code for when a button is pressed it copies the range A13:Q75
and pastes to an external excel sheet. The trouble i'm having now is if the
user presses the button again i need the information to continue from the end
of the external excel list and paste that in instead of overwriting the
current data.

Please help


Dim lngRow As Long, rngTemp As Range
Dim wbBook As Workbook, wsDest As Worksheet

Set rngTemp = ActiveSheet.Range("A13:Q75")
Set wbBook = Workbooks.Open("C:\Documents and
Settings\neil.holden\Desktop\test2.xls")
Set wsDest = wbBook.Sheets("Sheet1") 'Destination sheet
With rngTemp
wsDest.Range("A2").Resize(.Rows.Count, .Columns.Count).Value = .Value
lngRow = wsDest.Cells(Rows.Count, "A").End(xlUp).Row + 1
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default MACRO HELP CONTINUED

I replied to an earlier question - but obviously got it wrong. Sorry.

so do you just want the data appended to data thates there already?

change this line

wsDest.Range("A2").Resize(.Rows.Count, .Columns.Count).Value = .Value

to
wsDest.Range("A2").End(xlDown).Offset(1).Resize(.R ows.Count,
..Columns.Count).Value = .Value

this will find the first empty cell below A1 and copy the block of data

"Neil Holden" wrote:


Below is the code for when a button is pressed it copies the range A13:Q75
and pastes to an external excel sheet. The trouble i'm having now is if the
user presses the button again i need the information to continue from the end
of the external excel list and paste that in instead of overwriting the
current data.

Please help


Dim lngRow As Long, rngTemp As Range
Dim wbBook As Workbook, wsDest As Worksheet

Set rngTemp = ActiveSheet.Range("A13:Q75")
Set wbBook = Workbooks.Open("C:\Documents and
Settings\neil.holden\Desktop\test2.xls")
Set wsDest = wbBook.Sheets("Sheet1") 'Destination sheet
With rngTemp
wsDest.Range("A2").Resize(.Rows.Count, .Columns.Count).Value = .Value
lngRow = wsDest.Cells(Rows.Count, "A").End(xlUp).Row + 1

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 163
Default MACRO HELP CONTINUED

I have done that and comes back with an error: Application defined error.

Thanks anyhow.

"Patrick Molloy" wrote:

I replied to an earlier question - but obviously got it wrong. Sorry.

so do you just want the data appended to data thates there already?

change this line

wsDest.Range("A2").Resize(.Rows.Count, .Columns.Count).Value = .Value

to
wsDest.Range("A2").End(xlDown).Offset(1).Resize(.R ows.Count,
.Columns.Count).Value = .Value

this will find the first empty cell below A1 and copy the block of data

"Neil Holden" wrote:


Below is the code for when a button is pressed it copies the range A13:Q75
and pastes to an external excel sheet. The trouble i'm having now is if the
user presses the button again i need the information to continue from the end
of the external excel list and paste that in instead of overwriting the
current data.

Please help


Dim lngRow As Long, rngTemp As Range
Dim wbBook As Workbook, wsDest As Worksheet

Set rngTemp = ActiveSheet.Range("A13:Q75")
Set wbBook = Workbooks.Open("C:\Documents and
Settings\neil.holden\Desktop\test2.xls")
Set wsDest = wbBook.Sheets("Sheet1") 'Destination sheet
With rngTemp
wsDest.Range("A2").Resize(.Rows.Count, .Columns.Count).Value = .Value
lngRow = wsDest.Cells(Rows.Count, "A").End(xlUp).Row + 1

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default MACRO HELP CONTINUED

the error occurs if there's currently nothing in the destination sheet. so
switch End(xlDown) to XLUP

change this
wsDest.Range("A2").End(xlDown).Offset(1).Resize(.R ows.Count,
..Columns.Count).Value = .Value

to

wsDest.Range("A" & Rows.Count).End(xlUp).Offset(1).Resize(.Rows.Count ,
..Columns.Count).Value = .Value



"Neil Holden" wrote:

I have done that and comes back with an error: Application defined error.

Thanks anyhow.

"Patrick Molloy" wrote:

I replied to an earlier question - but obviously got it wrong. Sorry.

so do you just want the data appended to data thates there already?

change this line

wsDest.Range("A2").Resize(.Rows.Count, .Columns.Count).Value = .Value

to
wsDest.Range("A2").End(xlDown).Offset(1).Resize(.R ows.Count,
.Columns.Count).Value = .Value

this will find the first empty cell below A1 and copy the block of data

"Neil Holden" wrote:


Below is the code for when a button is pressed it copies the range A13:Q75
and pastes to an external excel sheet. The trouble i'm having now is if the
user presses the button again i need the information to continue from the end
of the external excel list and paste that in instead of overwriting the
current data.

Please help


Dim lngRow As Long, rngTemp As Range
Dim wbBook As Workbook, wsDest As Worksheet

Set rngTemp = ActiveSheet.Range("A13:Q75")
Set wbBook = Workbooks.Open("C:\Documents and
Settings\neil.holden\Desktop\test2.xls")
Set wsDest = wbBook.Sheets("Sheet1") 'Destination sheet
With rngTemp
wsDest.Range("A2").Resize(.Rows.Count, .Columns.Count).Value = .Value
lngRow = wsDest.Cells(Rows.Count, "A").End(xlUp).Row + 1

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
Continued issues Ric[_7_] Excel Programming 2 February 22nd 09 01:41 AM
Median continued Bony Pony[_2_] Excel Discussion (Misc queries) 12 December 10th 08 06:53 AM
macro doesn't compile after module crashed continued from scary th Janis Excel Programming 8 August 30th 06 08:04 PM
Macro To Change Cell Color (Continued) carl Excel Worksheet Functions 0 March 15th 06 03:10 PM
Continued Conversion of data from rows to columns in a macro. Karaman Excel Programming 5 March 3rd 05 03:29 PM


All times are GMT +1. The time now is 01:00 PM.

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

About Us

"It's about Microsoft Excel"