Delete Blank Cells

billfold

New Member
Joined
Apr 30, 2012
Messages
6
So, I need some help deleting blank cells, or adjusting my code to only copy cells in the range that have a value. Here are the steps:


  1. Copy Range B2:B2000 (which has formulas in it)
  2. Paste the Values of that Range into J2:J2000
  3. Then copy that range however many times the user wants it copied into one column. I was able to get this to work, but there are blanks copied over.

Also, this site always used to come up when I would search for some excel answers, but for some reason never pops up anymore.

Here is the code:

Code:
Sub copy()
Dim mR As Range


Worksheets("UserStoreList").Range("B2:B2000").Copy
Worksheets("UserStoreList").Range("J2:J2000").PasteSpecial xlPasteValues


Set mR = Worksheets("UserStoreList").Range("J2:J2000")
Dim HowManyTimes As Integer: HowManyTimes = Worksheets("US Form").Range("D52")


mR.Copy Worksheets("Sheet2").Range("A2").Offset(0).Resize(mR.Rows.Count * HowManyTimes)


Worksheets("UserStoreList").Range("J2:J2000").Delete


End Sub

Thank you for your help everyone.
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Try
Code:
Sub billfold()
Dim mR As Range


With Worksheets("UserStoreList")
   .Range("J2:J2000").Value = .Range("B2:B2000").Value
   .Range("J2:J2000").SpecialCells(xlBlanks).Delete xlUp
   Set mR = .Range("J2", .Range("J" & Rows.Count).End(xlUp))
End With
Dim HowManyTimes As Integer: HowManyTimes = Worksheets("US Form").Range("D52")


mR.copy Worksheets("Sheet2").Range("A2").Offset(0).Resize(mR.Rows.Count * HowManyTimes)


Worksheets("UserStoreList").Range("J2:J2000").Delete


End Sub
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,251
Members
448,556
Latest member
peterhess2002

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