Copy and past non blank cells

jtodd

Board Regular
Joined
Aug 4, 2014
Messages
155
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
 

Some videos you may like

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

igold

Well-known Member
Joined
Jul 8, 2014
Messages
2,506
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
155
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,506
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
155

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,506
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
155
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??
 

Watch MrExcel Video

Forum statistics

Threads
1,123,270
Messages
5,600,637
Members
414,398
Latest member
dhune

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