Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Reggie
 
Posts: n/a
Default Non Blank - Blank Cells????

I have a very large spreadsheet that was given to me by someone who created
it from a database. I need to do a CountA to help sort it. But the "empty"
cells, which look blank to me, are not. So the CountA counts every cell.

Would you know how I can get the cells that look empty to be seen as blank
so I can do a valid CountA?
  #2   Report Post  
Dave O
 
Posts: n/a
Default

Here's a solution for you. Step 1, of course, is to make a backup copy
of your data so you don't lose anything! Then copy this code, and
paste it in as a macro.

It stores the value of each cell to memory if the cell does not contain
a formula, deletes the contents of the cell, and rewrites the stored
value into the cell.

Sub TrueVal_Tab()
'Converts apparently non-blank cells, such as those containing
'spaces or an apostrophe, to blank cells in the current tab of
'a workbook. Useful for data imported from a database.

'Use and distribute freely. If you find this useful, and particularly
'if you are in a corporate setting and this bails you out of a serious
'jam, ask your company to make a donation to the American Diabetes
'Association, or the national Diabetes Foundation in your country.

'Set calc to manual
With Application
..Calculation = xlManual
..MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False

Dim TrueVal
Dim Rows As Long, Columns As Long
Dim R As Long, C As Long

'determine lower right corner of this tab
ActiveCell.SpecialCells(xlLastCell).Select
Rows = Selection.Row
Columns = Selection.Column
'return to a1
Range("a1").Select

'Begin FOR loop to cycle through columns and rows
For C = 0 To Columns - 1
For R = 0 To Rows - 1

'if the cell contains a formula, skip
If Len(ActiveCell.Offset(R, C).Formula) 0 Then GoTo Bailout:
TrueVal = Trim(ActiveCell.Offset(R, C).Value)
ActiveCell.Offset(R, C).Value = ""
ActiveCell.Offset(R, C).Value = TrueVal

Bailout:
Next R
Next C

'set calc to auto
With Application
..Calculation = xlAutomatic
..MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False

Calculate
End Sub

  #3   Report Post  
Dave O
 
Posts: n/a
Default

I posted a response earlier- or thought I did- but it has not appeared
yet. The code in that post is buggy, and should be replaced with the
following code.

Copy this code and paste it in as a macro. It stores the value of each
cell in a tab (except cells that contain formulas) to memory, erases
the contents of the cell, and replaces the contents with the scrubbed
value: no apostrophes, blanks, etc.

Sub TrueVal_Tab()
'Converts apparently non-blank cells, such as those containing
'spaces or an apostrophe, to blank cells in the current tab of
'a workbook. Useful for data imported from a database.

'Use and distribute freely. If you find this useful, and particularly
'if you are in a corporate setting and this bails you out of a serious
'jam, ask your company to make a donation to the American Diabetes
'Association, or the national Diabetes Foundation in your country.

'Set calc to manual
With Application
..Calculation = xlManual
..MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False

Dim TrueVal
Dim CurrentFormat As String
Dim Rows As Long, Columns As Long
Dim R As Long, C As Long

'determine lower right corner of this tab
ActiveCell.SpecialCells(xlLastCell).Select
Rows = Selection.Row
Columns = Selection.Column
'return to a1
Range("a1").Select

'Begin FOR loop to cycle through columns and rows
For C = 0 To Columns - 1
For R = 0 To Rows - 1

'if the cell contains a formula, skip
If Mid(ActiveCell.Offset(R, C).Formula, 1, 1) < "=" Then
TrueVal = Trim(ActiveCell.Offset(R, C).Value)
ActiveCell.Offset(R, C).Value = ""
ActiveCell.Offset(R, C).Value = TrueVal
End If

Next R
Next C

'set calc to auto
With Application
..Calculation = xlAutomatic
..MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False

Calculate
End Sub

  #4   Report Post  
Dave Peterson
 
Posts: n/a
Default

You've looked at those cells and verified that the previous owner didn't put
space characters in the cells???

You can use =len(a1) to see if what's there is has a length larger than 0.

===
But if you have formulas that evaluate to ""
like:

=if(a1="ok",b1+c1,"")

And then convert to values, then this could be the culprit.

Just to verify...
Select an offending cell.
then hit tools|options|transition tab|turn on "transition navigation keys"
then ok your way out.
Look at the formula bar. Do you see an apostrophe?

If yes, then you've found the problem.

I do this (either in code or manually).

Select all the cells
edit|replace
what: (Leave empty--no space, not anything)
with: $$$$$ (some unique set of characters)
replace all

Then once more
edit|replace
What: $$$$$ (same unique set of characters)
with: (Leave empty--no space, not anything)
replace all

(Replace will limit itself to the used range, so you don't have to worry about
going to IV65536.)

Now select one of those previously offending cells.
look at the formula bar. (TaDa!)

Don't forget to turn this off:
tools|options|transition tab|"transition navigation keys"

It does stuff that most excel users don't like.

Reggie wrote:

I have a very large spreadsheet that was given to me by someone who created
it from a database. I need to do a CountA to help sort it. But the "empty"
cells, which look blank to me, are not. So the CountA counts every cell.

Would you know how I can get the cells that look empty to be seen as blank
so I can do a valid CountA?


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Skip blank cells in diagrams hlp Charts and Charting in Excel 9 February 24th 06 02:32 PM
In Exel 2000, stop the blank cells (with formulas) from printing. tonyoc Excel Discussion (Misc queries) 1 December 10th 04 12:38 AM
how to skip the blank cells nayeemoddin Excel Discussion (Misc queries) 1 December 6th 04 07:07 AM
copy blank cells Vicneswari Murugan Excel Discussion (Misc queries) 1 December 1st 04 02:12 PM
copy blank cells Vicneswari Murugan Excel Discussion (Misc queries) 0 December 1st 04 03:33 AM


All times are GMT +1. The time now is 09:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"