Copy & Paste - ignore blank drop down cells

Charmwah

Board Regular
Joined
Jan 23, 2017
Messages
64
Hi all

I'm trying to copy a selection from one worksheet and paste it to another. The range varies depending on the time of the month, and so I only need to copy data up until the first blank row. I have a simple code to do this, however I think its seeing a blank drop-down cell as live cell and so is copying all these blanks rather than stopping at that point. Can anyone suggest a way around this?

My simple code is:

Code:
Private Sub Gather_data()
    Dim All As Long
    All = Cells(1, 1).End(xlDown).Row
'Copy the data
    Sheets("March 2017").Range("D1:Z" & All).Copy
'Activate the destination worksheet
    Sheets("Pivot2").Activate
'Select the target range
    Range("D1").Select
'Paste in the target destination
    ActiveSheet.Paste
    Application.CutCopyMode = False
    Worksheets("Pivot2").Columns("D:Z").AutoFit
End Sub
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

Forum statistics

Threads
1,216,069
Messages
6,128,599
Members
449,460
Latest member
jgharbawi

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