Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / November 2007

Tip: Looking for answers? Try searching our database.

Finding blank cell

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
gane - 21 Nov 2007 13:06 GMT
Hai iam creating standard template where cells having different formulas &
validation. My query is i dont want to left any cells blank. Is there any
macro to find the blank cell (within certain range) and if it find blank
cell, error message has to come stating  particular cell number is blank.
Mike H - 21 Nov 2007 13:30 GMT
Hi,

Right click the sheet tab, view code and paste this in.

Sub blanks()
Set myrange = Range("A1:A100") 'Change to suit
   For Each c In myrange
       If found <> 1 And IsEmpty(c.Value) Then
           found = 1
           myAddress = c.Address
           ElseIf found = 1 And IsEmpty(c.Value) Then
           Count = Count + 1
       End If
   Next
   MsgBox myAddress & " has not been populated and there are " _
   & Count & " other blanks"
End Sub

Mike

> Hai iam creating standard template where cells having different formulas &
> validation. My query is i dont want to left any cells blank. Is there any
> macro to find the blank cell (within certain range) and if it find blank
> cell, error message has to come stating  particular cell number is blank.
gane - 21 Nov 2007 14:14 GMT
Thanks mike
itz working fine . but if all the cells are filled i want to show separate
message that all cells are filled.

> Hi,
>
[quoted text clipped - 20 lines]
> > macro to find the blank cell (within certain range) and if it find blank
> > cell, error message has to come stating  particular cell number is blank.
Mike H - 21 Nov 2007 15:21 GMT
Then use this moddified version:-

Sub blanks()
Set myrange = Range("A1:A10") 'Change to suit
   For Each c In myrange
       If found <> 1 And IsEmpty(c.Value) Then
           found = 1
           myAddress = c.Address
           ElseIf found = 1 And IsEmpty(c.Value) Then
           Count = Count + 1
       End If
   Next
   If Count > 0 Then
   MsgBox myAddress & " has not been populated and there are " _
   & Count & " other blanks"
   Else
   MsgBox "All cells filled"
   End If
End Sub

Mike

> Thanks mike
> itz working fine . but if all the cells are filled i want to show separate
[quoted text clipped - 24 lines]
> > > macro to find the blank cell (within certain range) and if it find blank
> > > cell, error message has to come stating  particular cell number is blank.
Mike Fogleman - 21 Nov 2007 15:39 GMT
That will fail if only 1 cell is left blank. Need to use found as the
criteria.

Sub blanks()
Dim myrange As Range, c As Range
Dim found As Integer
Dim myaddress As String
Dim count As Long
Set myrange = Range("A1:A10") 'Change to suit
   For Each c In myrange
       If found <> 1 And IsEmpty(c.Value) Then
           found = 1
           myaddress = c.Address
           ElseIf found = 1 And IsEmpty(c.Value) Then
           count = count + 1
       End If
   Next
If found = 1 Then
   MsgBox myaddress & " has not been populated and there are " _
   & count & " other blanks"
Else
   MsgBox "All cells are filled"
End If
End Sub

Mike F
> Then use this moddified version:-
>
[quoted text clipped - 51 lines]
>> > > cell, error message has to come stating  particular cell number is
>> > > blank.
gane - 22 Nov 2007 08:11 GMT
Thanks itz working great. In addition to this ............
I had assign this macro to a command button in excel sheet. By pressing the
button the macro is working fine. I want to automatically disappear/hide that
command button once after the message box shows 0 blank cells

> That will fail if only 1 cell is left blank. Need to use found as the
> criteria.
[quoted text clipped - 77 lines]
> >> > > cell, error message has to come stating  particular cell number is
> >> > > blank.
Mike Fogleman - 22 Nov 2007 13:04 GMT
Put these lines wherever you want to show/hide the button. Change the sheet
reference to your sheet with the button.

Sheet1.CommandButton1.Visible = True
Sheet1.CommandButton1.Visible = False

Mike F
> Thanks itz working great. In addition to this ............
> I had assign this macro to a command button in excel sheet. By pressing
[quoted text clipped - 85 lines]
>> >> > > cell, error message has to come stating  particular cell number is
>> >> > > blank.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.