![]() |
|
#1
|
|||
|
|||
|
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
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.... |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| won't show blank cell | bhum | Excel | 2 | 01-28-2014 02:34 AM |
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 |
How to turn all blank lines into non-blank for legal forms
|
sieler | Word | 3 | 04-12-2009 01:38 PM |