LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Checking for blank rows in database - with apologies to Norman Jon

Hi Peter,

Define a name ("MyDatabase") for the database area, and replace the previous
code with:

'======================
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
Dim rng2 As Range
Dim rw As Range

Set rng = Range("MyDatabase") '<<===== DEFINE
Set rng2 = Intersect(rng, Target.EntireRow)


If Not rng2 Is Nothing Then
For Each rw In rng2.Rows
If Application.CountA(rw.Cells) = 0 Then
MsgBox ("Database row " & rw.Row _
& " is empty. You CAN'T have " _
& "blank rows in the database!")
End If
Next
End If
End Sub
'<<'======================


---
Regards,
Norman



"Peter Rooney" wrote in message
...
Good morning all!
The reason for the apology to Norman is I started a different thread
yesterday where he was helping me, but I can't find it at work this
morning,
so I hope he doesn't think I'm being rude!

I'm working with a database that occupies columns B:L and I'm trying to
prevent users from having a row where Bx:Lx contains all blank cells, as I
use currentregion to add and delete rows, and it doesn;t work properly if
it
encounters a blank row.

This is what I tried in my Worksheet_Change macro (which works in all
other
respects). I'm attempting a multiple IF statement to check each cell in
the
current row from column B to column L. If all cells are empty, a value is
entered into column F of the current row.

The problem is that although no error messages are displayed syntax,
the
code just doesn't work when I empty all the cells between column B and
column
L in the current row. I've tried this in lots of flavours, including IF
len("B" & .row) = 0, but nothing seems to work. I guess it's something do
do
with the way in which I'm trying to concatenate the column letter and the
.row of the Target, but I'm now completely stumped.

Can any of you good people out there on a Monday morning give me a hand?

Thanks in advance (and to you too, Norman for helping a sad old man with
nothing better to do on a Sunday afternoon!)

Pete

With Target

'---------------------------------------------------------------------------------
If .Column = 2 Then
If .Column <= 12 Then
If Application.isblank("B" & .Row) Then
If Application.isblank("C" & .Row) Then
If Application.isblank("D" & .Row) Then
If Application.isblank("E" & .Row) Then
If Application.isblank("F" & .Row) Then
If Application.isblank("G" & .Row) Then
If Application.isblank("H" & .Row) Then
If Application.isblank("I" & .Row) Then
If Application.isblank("J" & .Row) Then
If Application.isblank("K" & .Row) Then
If Application.isblank("L" & .Row) Then
MsgBox ("You CAN'T have blank rows in the
database!")
Range("F" & Target.Row).Formula = "Blank
Eliminator"
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If




 
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
Database for checking out books Craig Excel Discussion (Misc queries) 0 December 23rd 08 09:25 PM
Checking a list of new data against a database Martin French Excel Programming 4 February 21st 05 05:17 AM
checking if an access database is open from excel macro Keyur Excel Programming 0 April 16th 04 04:03 PM
Checking database field Chris Dunigan Excel Programming 2 November 24th 03 11:13 AM
checking if worksheet is blank Tommi[_2_] Excel Programming 1 November 2nd 03 03:59 PM


All times are GMT +1. The time now is 08:31 AM.

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"