Copy and past non blank cells

jtodd

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

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
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:
Upvote 0
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
 
Upvote 0
Great, glad I could help. Thanks for the feedback.


igold
 
Upvote 0
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 ??
 
Upvote 0
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
 
Upvote 0
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??
 
Upvote 0

Forum statistics

Threads
1,214,642
Messages
6,120,698
Members
448,979
Latest member
DET4492

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