Copy and past non blank cells

jtodd

Board Regular
Joined
Aug 4, 2014
Messages
179
What I need is to copy and past data only - Skip blanks
This works if i use paste special but cannot make it work using vba see below.

Sheets("Tracker2").Select
Range("D3:h431").Select
Selection.Copy
Sheets("Tracker").Select
Range("C3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

Help
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

igold

Well-known Member
Joined
Jul 8, 2014
Messages
2,851
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Hi jtodd,

This is really a work around as far as I am concerned but what the heck. Try it and see if it does what you want.

Please remember to run the code on a backup copy of your data.

Code:
Sub DelBlanks()

Dim wsT2 As Worksheet: Set wsT2 = Worksheets("Tracker2")
Dim wsT As Worksheet: Set wsT = Worksheets("Tracker")

wsT2.Range("D3:h431").Copy
wsT.Range("C3").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=True, Transpose:=False
wsT.Range("C3:H431").SpecialCells(xlCellTypeBlanks).Delete

End Sub


HTH

igold
 
Last edited:

jtodd

Board Regular
Joined
Aug 4, 2014
Messages
179
Hi jtodd,


This is really a work around as far as I am concerned but what the heck. Try it and see if it does what you want.

Please remember to run the code on a backup copy of your data.

Code:
Sub DelBlanks()

Dim wsT2 As Worksheet: Set wsT2 = Worksheets("Tracker2")
Dim wsT As Worksheet: Set wsT = Worksheets("Tracker")

wsT2.Range("D3:h431").Copy
wsT.Range("C3").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=True, Transpose:=False
wsT.Range("C3:H431").SpecialCells(xlCellTypeBlanks).Delete

End Sub


HTH

igold

I'm good with a workaround as long as it works , and it does.

Thanks for your time
 

igold

Well-known Member
Joined
Jul 8, 2014
Messages
2,851
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Great, glad I could help. Thanks for the feedback.


igold
 

jtodd

Board Regular
Joined
Aug 4, 2014
Messages
179

ADVERTISEMENT

I'm good with a workaround as long as it works , and it does.

Thanks for your time


Sorry but I have come across a problem , if the cell is has a formula in it but no data -blank- it coppies the blank cell , is there a way round this ??
 

igold

Well-known Member
Joined
Jul 8, 2014
Messages
2,851
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Try this... Again not the perfect answer...

Remember, test on backup copy of data.

Code:
Sub DelBlanks()

Dim wsT2 As Worksheet: Set wsT2 = Worksheets("Tracker2")
Dim wsT As Worksheet: Set wsT = Worksheets("Tracker")

wsT2.Range("d3:h431").Copy
wsT.Range("C3").PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:=True, Transpose:=False
wsT.Range("C3:H431").SpecialCells(xlFormulas).Delete shift:=xlShiftUp
wsT.Range("C3:H431").SpecialCells(xlCellTypeBlanks).Delete
End Sub

igold
 

jtodd

Board Regular
Joined
Aug 4, 2014
Messages
179
Try this... Again not the perfect answer...

Remember, test on backup copy of data.

Code:
Sub DelBlanks()

Dim wsT2 As Worksheet: Set wsT2 = Worksheets("Tracker2")
Dim wsT As Worksheet: Set wsT = Worksheets("Tracker")

wsT2.Range("d3:h431").Copy
wsT.Range("C3").PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:=True, Transpose:=False
wsT.Range("C3:H431").SpecialCells(xlFormulas).Delete shift:=xlShiftUp
wsT.Range("C3:H431").SpecialCells(xlCellTypeBlanks).Delete
End Sub

igold

Sorry but I cannot get this to work ,
It copies and pastes data from Tracker 2 j3:n3 and all.
Changed the xlPasteAll to xlPasteValue and get a debug message??
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,987
Messages
5,834,722
Members
430,313
Latest member
smartykatwinks

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
Top