Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-28-2014, 01:29 PM
bremen22 bremen22 is offline Row Looks to be blank but its not Windows 7 64bit Row Looks to be blank but its not Office 2010 64bit
Advanced Beginner
Row Looks to be blank but its not
 
Join Date: Jul 2013
Posts: 44
bremen22 is on a distinguished road
Default Row Looks to be blank but its not


I have a workbook that I use to reformat data from its original format into the format I want.

In that workbook there is a macro that deletes all of the blank rows on the main sheet

Code:
Sub delblankrows()

Dim s1 As Worksheet
Dim tmpR As Range
Dim rowcount As Long, colcount As Long, i As Long, j As Long, k As Boolean

'Change "Sheet1" to the name of your worksheet.
Set s1 = Sheets("sheet1")
Set tmpR = s1.UsedRange
rowcount = tmpR.Rows.Count
colcount = tmpR.Columns.Count

'Starts from bottom row and looks for non-empty cells from left to right.
'Moves to row above if non-empty cell is found.
'If none is found, then deletes row and shifts values up.
For i = rowcount To 1 Step -1
    k = 0
    For j = 1 To colcount
        If tmpR.Value2(i, j) <> "" Then
            k = 1
            Exit For
        End If
    Next j
I have used this line of code in numerous other sheets and it works fine. In this book, however, there are rows that appear empty but when I run the macro those do not get deleted.

When I select the row and "clear contents" and run the macro again the row gets deleted.

I dont even know where to start figuring this one out....
Reply With Quote
  #2  
Old 01-28-2014, 03:50 PM
bremen22 bremen22 is offline Row Looks to be blank but its not Windows 7 64bit Row Looks to be blank but its not Office 2010 64bit
Advanced Beginner
Row Looks to be blank but its not
 
Join Date: Jul 2013
Posts: 44
bremen22 is on a distinguished road
Default Update

After giving some more thought to this problem I think this might be relevant.

There are other macros that I run to delete unwanted data. A sample is

Code:
Sub DELData()
'
' DELData Macro
'

'
    Sheets("Sheet1").Select
    Application.CutCopyMode = False
    Selection.Copy
    Cells.Replace What:="Sample Text", Replacement:="", LookAt _
        :=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
    Sheets("Control").Select
End Sub
I used this in another workbook to do the exact same thing. This worked fine in the other book. Now it seems that even though it is replacing the data to "" there is still something lingering. The rows that are not being deleted by the macro posted in my first post are all rows that have text replaced
Reply With Quote
  #3  
Old 01-29-2014, 09:07 AM
BobBridges's Avatar
BobBridges BobBridges is offline Row Looks to be blank but its not Windows 7 64bit Row Looks to be blank but its not Office 2010 32bit
Expert
 
Join Date: May 2013
Location: USA
Posts: 700
BobBridges has a spectacular aura aboutBobBridges has a spectacular aura about
Default

I can't give you a complete answer on this, bremen22; I have yet to work out a complete theory of the contents of a cell. But I can agree with your observation; cells that I change from something to "" are not quite the same as cells that never had anything in them in the first place. I'm pretty sure I have sometimes done an <End>,<Down> in a column and have it stop at a cell that used to have something in it and now doesn't.

I'm not sure, but I've a notion that hitting <Del> clears that status. If I'm right, that implies that an empty string is still data ... which from a programmer's point of view makes sense, actually. So my guess is that a cell with "" in it is not yet Empty, but after I hit <Del>, or in your case after you ClearContents, then it's Empty.

All this makes sounds so obvious now that I'm writing it down, but I've never sat down to think about it carefully before. I guess I'll have to experiment a bit.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
won't show blank cell bhum Excel 2 01-28-2014 02:34 AM
Row Looks to be blank but its not Document comes up as a blank Grover Word 1 11-29-2013 07:24 PM
Page numberring 1 - blank - 2 - blank etc Intern PowerPoint 0 09-02-2011 01:16 AM
hidden blank pages mljm Word 3 06-19-2009 03:18 AM
Row Looks to be blank but its not How to turn all blank lines into non-blank for legal forms sieler Word 3 04-12-2009 01:38 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:28 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft