Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default Copy/paste macro blocking

Dear All,

I prepared a code that should:
- copy last used line from currently used workbook
- paste it to the first free line on all other opened workbooks

For some reason, the code blocks on the line:
FirstFreeRow = Range("B7").End(xlDown + 1).Row


Can you tell me what should I modify?
Thanks a lot,
Mark
-----------------
Here's the code:

Sub Macro7()

Dim wbk As Workbook

lastDataRow = Range("B7").End(xlDown).Row
Range("B" & lastDataRow).Select
Range(ActiveCell, ActiveCell.Offset(0, 9)).Select
Selection.Copy

'it would be also useful to exclude the file we just used, but at the end I
can also live without it (=delete the double row manually after the macro is
executed)
For Each wbk In Application.Workbooks
wbk.Activate
Worksheets("Sheet1").Activate
FirstFreeRow = Range("B7").End(xlDown + 1).Row
Range("B" & FirstFreeRow).Select
Selection.Paste
Next wbk

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 269
Default Copy/paste macro blocking

Your closing parenthesis in the wrong place.
FirstFreeRow = Range("B7").End(xlDown).Row+1
James
markx wrote:
Dear All,

I prepared a code that should:
- copy last used line from currently used workbook
- paste it to the first free line on all other opened workbooks

For some reason, the code blocks on the line:
FirstFreeRow = Range("B7").End(xlDown + 1).Row


Can you tell me what should I modify?
Thanks a lot,
Mark
-----------------
Here's the code:

Sub Macro7()

Dim wbk As Workbook

lastDataRow = Range("B7").End(xlDown).Row
Range("B" & lastDataRow).Select
Range(ActiveCell, ActiveCell.Offset(0, 9)).Select
Selection.Copy

'it would be also useful to exclude the file we just used, but at the end I
can also live without it (=delete the double row manually after the macro is
executed)
For Each wbk In Application.Workbooks
wbk.Activate
Worksheets("Sheet1").Activate
FirstFreeRow = Range("B7").End(xlDown + 1).Row
Range("B" & FirstFreeRow).Select
Selection.Paste
Next wbk

End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default Copy/paste macro blocking

Hi, thanks...

It's strange, because it only puts the problem to the next line of code...

Code stops at:
Range("B" & FirstFreeRow).Select

I'll try to work on this, but if you have a clue what's going wrong, pls let
know...
Cheers,

Mark


"Zone" wrote in message
ups.com...
Your closing parenthesis in the wrong place.
FirstFreeRow = Range("B7").End(xlDown).Row+1
James
markx wrote:
Dear All,

I prepared a code that should:
- copy last used line from currently used workbook
- paste it to the first free line on all other opened workbooks

For some reason, the code blocks on the line:
FirstFreeRow = Range("B7").End(xlDown + 1).Row


Can you tell me what should I modify?
Thanks a lot,
Mark
-----------------
Here's the code:

Sub Macro7()

Dim wbk As Workbook

lastDataRow = Range("B7").End(xlDown).Row
Range("B" & lastDataRow).Select
Range(ActiveCell, ActiveCell.Offset(0, 9)).Select
Selection.Copy

'it would be also useful to exclude the file we just used, but at the end
I
can also live without it (=delete the double row manually after the macro
is
executed)
For Each wbk In Application.Workbooks
wbk.Activate
Worksheets("Sheet1").Activate
FirstFreeRow = Range("B7").End(xlDown + 1).Row
Range("B" & FirstFreeRow).Select
Selection.Paste
Next wbk

End Sub




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 269
Default Copy/paste macro blocking

markx, Did you dim FirstFreeRow as Long? When the code chokes, go into
debug and rest the mouse over FirstFreeRow on the highlighted line. It
should show the value of FirstFreeRow. What is it? James
markx wrote:
Hi, thanks...

It's strange, because it only puts the problem to the next line of code...

Code stops at:
Range("B" & FirstFreeRow).Select

I'll try to work on this, but if you have a clue what's going wrong, pls let
know...
Cheers,

Mark


"Zone" wrote in message
ups.com...
Your closing parenthesis in the wrong place.
FirstFreeRow = Range("B7").End(xlDown).Row+1
James
markx wrote:
Dear All,

I prepared a code that should:
- copy last used line from currently used workbook
- paste it to the first free line on all other opened workbooks

For some reason, the code blocks on the line:
FirstFreeRow = Range("B7").End(xlDown + 1).Row


Can you tell me what should I modify?
Thanks a lot,
Mark
-----------------
Here's the code:

Sub Macro7()

Dim wbk As Workbook

lastDataRow = Range("B7").End(xlDown).Row
Range("B" & lastDataRow).Select
Range(ActiveCell, ActiveCell.Offset(0, 9)).Select
Selection.Copy

'it would be also useful to exclude the file we just used, but at the end
I
can also live without it (=delete the double row manually after the macro
is
executed)
For Each wbk In Application.Workbooks
wbk.Activate
Worksheets("Sheet1").Activate
FirstFreeRow = Range("B7").End(xlDown + 1).Row
Range("B" & FirstFreeRow).Select
Selection.Paste
Next wbk

End Sub



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default Copy/paste macro blocking

OK, I understand it better now - didn't know that you can actually see the
value of the variable...
First Free Row was 65537 (on one of the worksheets, there was no record
under B7, so it went to the very last row on the worksheet).
So if I want to use this code, I should find some solution for this kind of
situations... Were you already confronted with this?
* * *
By the way, I used another code, going from the bottom of the worksheet...
it works!
Only needed to change Selection.Paste to ActiveSheet.Paste (don't know
exactly why...)
---------------
Sub TheCodeThatWorks()

Dim wbk As Workbook

lastDataRow = Range("B7").End(xlDown).Row
Range("B" & lastDataRow).Select
Range(ActiveCell, ActiveCell.Offset(0, 9)).Select
Selection.Copy

For Each wbk In Application.Workbooks
wbk.Activate
Worksheets("Sheet1").Activate
Lr = Sheets("sheet1").Range("B" & Rows.Count).End(xlUp).Offset(1, 0).Row
Range("B" & Lr).Select
ActiveSheet.Paste
Next wbk

End Sub


"Zone" wrote in message
ups.com...
markx, Did you dim FirstFreeRow as Long? When the code chokes, go into
debug and rest the mouse over FirstFreeRow on the highlighted line. It
should show the value of FirstFreeRow. What is it? James
markx wrote:
Hi, thanks...

It's strange, because it only puts the problem to the next line of
code...

Code stops at:
Range("B" & FirstFreeRow).Select

I'll try to work on this, but if you have a clue what's going wrong, pls
let
know...
Cheers,

Mark


"Zone" wrote in message
ups.com...
Your closing parenthesis in the wrong place.
FirstFreeRow = Range("B7").End(xlDown).Row+1
James
markx wrote:
Dear All,

I prepared a code that should:
- copy last used line from currently used workbook
- paste it to the first free line on all other opened workbooks

For some reason, the code blocks on the line:
FirstFreeRow = Range("B7").End(xlDown + 1).Row


Can you tell me what should I modify?
Thanks a lot,
Mark
-----------------
Here's the code:

Sub Macro7()

Dim wbk As Workbook

lastDataRow = Range("B7").End(xlDown).Row
Range("B" & lastDataRow).Select
Range(ActiveCell, ActiveCell.Offset(0, 9)).Select
Selection.Copy

'it would be also useful to exclude the file we just used, but at the
end
I
can also live without it (=delete the double row manually after the
macro
is
executed)
For Each wbk In Application.Workbooks
wbk.Activate
Worksheets("Sheet1").Activate
FirstFreeRow = Range("B7").End(xlDown + 1).Row
Range("B" & FirstFreeRow).Select
Selection.Paste
Next wbk

End Sub






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 269
Default Copy/paste macro blocking

I almost invariably go from the bottom up, so I don't run into this.
If you want to use xlDown, you could probably avoid the problem with
something like
If LastFreeRow65536 then LastFreeRow='something else!
Cheers!
James
markx wrote:
OK, I understand it better now - didn't know that you can actually see the
value of the variable...
First Free Row was 65537 (on one of the worksheets, there was no record
under B7, so it went to the very last row on the worksheet).
So if I want to use this code, I should find some solution for this kind of
situations... Were you already confronted with this?
* * *
By the way, I used another code, going from the bottom of the worksheet...
it works!
Only needed to change Selection.Paste to ActiveSheet.Paste (don't know
exactly why...)
---------------
Sub TheCodeThatWorks()

Dim wbk As Workbook

lastDataRow = Range("B7").End(xlDown).Row
Range("B" & lastDataRow).Select
Range(ActiveCell, ActiveCell.Offset(0, 9)).Select
Selection.Copy

For Each wbk In Application.Workbooks
wbk.Activate
Worksheets("Sheet1").Activate
Lr = Sheets("sheet1").Range("B" & Rows.Count).End(xlUp).Offset(1, 0).Row
Range("B" & Lr).Select
ActiveSheet.Paste
Next wbk

End Sub


"Zone" wrote in message
ups.com...
markx, Did you dim FirstFreeRow as Long? When the code chokes, go into
debug and rest the mouse over FirstFreeRow on the highlighted line. It
should show the value of FirstFreeRow. What is it? James
markx wrote:
Hi, thanks...

It's strange, because it only puts the problem to the next line of
code...

Code stops at:
Range("B" & FirstFreeRow).Select

I'll try to work on this, but if you have a clue what's going wrong, pls
let
know...
Cheers,

Mark


"Zone" wrote in message
ups.com...
Your closing parenthesis in the wrong place.
FirstFreeRow = Range("B7").End(xlDown).Row+1
James
markx wrote:
Dear All,

I prepared a code that should:
- copy last used line from currently used workbook
- paste it to the first free line on all other opened workbooks

For some reason, the code blocks on the line:
FirstFreeRow = Range("B7").End(xlDown + 1).Row


Can you tell me what should I modify?
Thanks a lot,
Mark
-----------------
Here's the code:

Sub Macro7()

Dim wbk As Workbook

lastDataRow = Range("B7").End(xlDown).Row
Range("B" & lastDataRow).Select
Range(ActiveCell, ActiveCell.Offset(0, 9)).Select
Selection.Copy

'it would be also useful to exclude the file we just used, but at the
end
I
can also live without it (=delete the double row manually after the
macro
is
executed)
For Each wbk In Application.Workbooks
wbk.Activate
Worksheets("Sheet1").Activate
FirstFreeRow = Range("B7").End(xlDown + 1).Row
Range("B" & FirstFreeRow).Select
Selection.Paste
Next wbk

End Sub



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
copy multiple worksheets of a workbook, and paste onto a Word document ( either create new doc file or paste onto an existing file.) I need this done by VBA, Excel Macro Steven Excel Programming 1 October 17th 05 08:56 AM
Non-blocking calls to Excel Macro using OLE Automation BW Excel Programming 5 August 3rd 05 09:13 PM
Copy and Paste macro needs to paste to a changing cell reference loulou Excel Programming 0 February 24th 05 10:29 AM
how to count/sum by function/macro to get the number of record to do copy/paste in macro tango Excel Programming 1 October 15th 04 01:16 PM
Macro to Copy/Paste then Paste to Next Line tomkarakowski Excel Programming 1 May 28th 04 01:19 AM


All times are GMT +1. The time now is 02:58 AM.

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"