code copies all rows?

orsm6

Active Member
Joined
Oct 3, 2012
Messages
496
Office Version
  1. 365
Platform
  1. Windows
Hi all - I hope this explanation makes sense. The code below was one i found here with a small modification to do what I needed.

I call the code via another macro.
Code:
Sub copyRawDataScholle()

Dim last_row As Long

'establishes last row in column A
    last_row = Range("A" & Rows.Count).End(xlUp).Row
   

'copies the raw data and pastes back to scraps file only as values.
    Workbooks("Finished Goods Yield Report - MASTER.xlsx").Worksheets("Scholle").Range("A2:z" & last_row).Copy
    Workbooks("AC22 Scraps.xlsm").Worksheets("YR - Scholle").Range("A2").PasteSpecial Paste:=xlPasteValues
    Workbooks("AC22 Scraps.xlsm").Activate
    Worksheets("Production Cycles").Select
   
' enable screen updating 
    Application.ScreenUpdating = True


End Sub

If I step through the code in macro window using F8 it only copies any columns with data to last cell in column A... which at the moment is A150.

but if I run the macro by calling it from the first Macro it seems to copy the data down to row 181.... the last non-blank cell is Z181.
I have checked and ensured there is no data from A151 down..... not sure why it is copying it all.

hope that made sense.
 
Last edited:

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Hello Orsm6,

It could be something as simple as having a space character inadvertently placed from A151 down. Select the remainder of Column A from A151 down and right click and select 'ClearContents'.

Cheerio,
vcoolio.
 
Upvote 0
Hello Orsm6,

It could be something as simple as having a space character inadvertently placed from A151 down. Select the remainder of Column A from A151 down and right click and select 'ClearContents'.

Cheerio,
vcoolio.
Thanks for your thoughts. I had already tried this :)
 
Upvote 0
Your last_row reference will be the currently activesheet.....tryt adding the workbook and / or sheetname to the line
 
Upvote 0
Solution
Your last_row reference will be the currently activesheet.....tryt adding the workbook and / or sheetname to the line
Oh that makes sense. Thanks very much, added the workbook and the sheet to that line and it solved it.
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,195
Members
449,072
Latest member
DW Draft

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top