Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 43
Default How to check if a row has nothing in it?

How do you check to see if a row has nothing in any of the cells in VBA?

I need to delete the row if there is nothing in it, and shift the rest of
the data up.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default How to check if a row has nothing in it?

Sub gsnu()
Dim j As Long
Dim i As Long
Dim r As Range
Dim r2 As Range
Set r2 = ActiveSheet.UsedRange

j = r2.Rows.Count + r2.Row - 1
For i = 1 To j
If Application.CountA(Rows(i)) = 0 Then
If r Is Nothing Then
Set r = Rows(i)
Else
Set r = Union(r, Rows(i))
End If
End If
Next i

If Not r Is Nothing Then
r.EntireRow.Delete
End If
End Sub

--
Gary''s Student - gsnu200736


"pokdbz" wrote:

How do you check to see if a row has nothing in any of the cells in VBA?

I need to delete the row if there is nothing in it, and shift the rest of
the data up.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 187
Default How to check if a row has nothing in it?

You could also do this with a formula, counting the blanks. =SUM(--
(ISBLANK(A1:Z1)) entered as an array formula sums all instances of
blank cells; if the sum equals 26 then you know the row is blank, etc.

This obviously is less automated than the VBA solution.

Dave


On Aug 7, 9:08 am, pokdbz wrote:
How do you check to see if a row has nothing in any of the cells in VBA?

I need to delete the row if there is nothing in it, and shift the rest of
the data up.



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
Check if Conditional Format is True or False / Check cell Color Kevin McCartney Excel Worksheet Functions 5 June 29th 07 11:12 AM
How do I increase the size of check in check boxes Adams, Les Excel Discussion (Misc queries) 0 September 19th 06 02:35 PM
Enable check box in protected sheet + group check boxes Dexxterr Excel Discussion (Misc queries) 4 August 2nd 06 12:00 PM
... Can I set Spell Check to automatically check my spelling ... Dr. Darrell Setting up and Configuration of Excel 0 March 21st 06 08:26 PM
check box, so when you click on it it inserts a check mark into t. Steve Excel Discussion (Misc queries) 2 April 13th 05 09:12 PM


All times are GMT +1. The time now is 08:18 PM.

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

About Us

"It's about Microsoft Excel"