You are here:

Excel/Delete Blank Cells

Advertisement


Question
QUESTION: Dear Bob

I have a following code to copy a range of cells to different rang in paste special manner;

Sub Update_Click()

With Sheets("Data")
.Range("ak6:av25").Copy
.Range("o6:z25").PasteSpecial xlPasteValues

  End With
End Sub

But the problem is this, after paste special in range o6:z25 even the cells which do not have value represents False when applied Isblank formula which means they are not blank (even nothing is pasted in them) this causes my graph (which depends upon this data) to behave unusually. To correct it, i have to manuall go to each empty cell and hit delete.

Can you correct the above code or provide some ammendment within same code which can delete those cells which are empty in range o6:z25 after paste special.

Regards
Adnan

ANSWER: Sub Update_Click()

With Sheets("Data")
.Range("ak6:av25").Copy
.Range("o6:z25").PasteSpecial xlPasteValues
'=======================
for each cl in .range("O6:Z25")
   if len(cl.value)=0 then cl.clear
Next
'=======================
  End With
End Sub

---------- FOLLOW-UP ----------

QUESTION: Dear Bob

Thanks, it works great but two issues:

1) it slows down the system and takes time not does the thing rapidly,, if you can do something to process it faster.

2) it also removes the cell boarders / lines which should remain.

Please advise

Regards
Adnan

Answer
Sub Update_Click()
Application.calculation=xlcalculationmanual
With Sheets("Data")
.Range("ak6:av25").Copy
.Range("o6:z25").PasteSpecial xlPasteValues
'=======================
for each cl in .range("O6:Z25")
   if len(cl.value)=0 then cl.clearcontents
Next
'=======================
  End With
Application.calculation=xlcalculationautomatic
End Sub
About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here

Excel

All Answers


Answers by Expert:


Ask Experts

Volunteer


Bob Umlas

Expertise

I`m a Microsoft Excel MVP (Most Valuable Professional) and have been since the inception of the program in 1995. I can answer every kind of Excel question except: API, Importing/exporting to other programs (powerpoint, word,...) Also check out my in-person training link at http://www.thumbtack.com/ny/new-york/excel-training/

Experience

Worked with MS Excel since version 0.99 (on the Mac!). Was contributing editor to Excellence Magazine, having written >300 articles. John Walkenbach said of me "I finally met someone who knows as much about Excel as I do."

Publications
Excellence, The Expert, Microsoft

Education/Credentials
BA in math, Hofstra University, 1965

Awards and Honors
MVP
Led sessions for the Convergence 2004-2006 seminar on Excel tips & tricks

©2016 About.com. All rights reserved.