Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 159
Default Writing an If Statement for group of cells

I have a group of cells in a template, on the single cell I can run the routine
If Worksheets("Inventory").Range("AG11") = "" Then
frmInventory.Hide
pswd.Protect "xxxxxx"
Exit Sub
End If
and it works great, but when I try to convert to cover several cells it
keeps on failing. The Range of Cells that I am trying to run a check on a
B25:B47, B50:B61, B64:B66, B86:B94,B103:B112,B114:B114,B116:B118,B120:b122,
etc. I named these group of cells oClearCells. Any help would be greatly
appreciated and very welcomed.

--
Larry E. Brueshaber
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Writing an If Statement for group of cells

Larry,
Give this a try, it assumes that you protecting the Inventory worksheet.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware

Sub BBB()
With Worksheets("Inventory")
If Application.CountA(.Range("oClearCells")) = .Range("oClearCells").Count Then
frmInventory.Hide
.Protect "xxxxxx"
Exit Sub
Else
MsgBox "Got some blanks "
End If
End With
End Sub
'------------

"Larry"

wrote in message
I have a group of cells in a template, on the single cell I can run the routine
If Worksheets("Inventory").Range("AG11") = "" Then
frmInventory.Hide
pswd.Protect "xxxxxx"
Exit Sub
End If
and it works great, but when I try to convert to cover several cells it
keeps on failing. The Range of Cells that I am trying to run a check on a
B25:B47, B50:B61, B64:B66, B86:B94,B103:B112,B114:B114,B116:B118,B120:b122,
etc. I named these group of cells oClearCells. Any help would be greatly
appreciated and very welcomed.
--
Larry E. Brueshaber
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Writing an If Statement for group of cells

Hi Larry,

Try something like:

'=============
Public Sub Tester001()
Dim rng As Range

Set rng = Range("B25:B47, B50:B61, B64:B66, B86:B94," _
& "B103:B112,B114:B114,B116:B118,B120:b122")

If Application.CountA(rng) = 0 Then
'Your code
Else
MsgBox "All the cells are not empty!"
End If
End Sub
'<<=============


---
Regards,
Norman


"Larry" wrote in message
...
I have a group of cells in a template, on the single cell I can run the
routine
If Worksheets("Inventory").Range("AG11") = "" Then
frmInventory.Hide
pswd.Protect "xxxxxx"
Exit Sub
End If
and it works great, but when I try to convert to cover several cells it
keeps on failing. The Range of Cells that I am trying to run a check on
a
B25:B47, B50:B61, B64:B66,
B86:B94,B103:B112,B114:B114,B116:B118,B120:b122,
etc. I named these group of cells oClearCells. Any help would be greatly
appreciated and very welcomed.

--
Larry E. Brueshaber



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
NEED HELP WRITING IF STATEMENT bumblebug Excel Discussion (Misc queries) 5 October 7th 08 01:34 PM
Writing IF Statement Angie Excel Worksheet Functions 4 June 5th 07 10:10 PM
Better way for writing IF statement ? monir Excel Programming 9 June 5th 06 01:12 PM
Help writing an IF statement cynichromantique Excel Worksheet Functions 6 April 1st 06 12:51 AM
need help in writing a statement susan hayes Excel Programming 3 September 28th 04 04:37 AM


All times are GMT +1. The time now is 10:46 PM.

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

About Us

"It's about Microsoft Excel"