View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Sandy Sandy is offline
external usenet poster
 
Posts: 355
Default Help With Code - Array and Range

Doug -

Thanks to you, it's up and running today! I just did a little tweaking for
things I didn't mention in my post.

Thank you soooooo much for sticking with me on it!!
--
Sandy


"Doug Glancy" wrote:

Sandy,

I'm sorry, I'm out of time until later today.

Have you looked at conditional formatting? I'm wondering if it wouldn't be
easier/more effective to highlight these various error situations on the
worksheet as they occur?

Good luck!

Doug

"Sandy" wrote in message
...
Hi again -

I did solve my problem with the following code and your code works
beautifully:
<snip
If (cell.Value = "No" Or cell.Value = "N/A") And Icell.Text = False Or
IsEmpty(Icell) Then
<snip
I do have another bigger problem, though. If the value in G is blank, I
have to return that also, so another scenario to be included is if G is
blank
and column I is blank also, both column addresses have to appear in the
MsgBox.

Let me know your thoughts on the above.


--
Sandy


"Doug Glancy" wrote:

Sandy,

I rewrote most of it. I hope this does what you want, or gives you some
help:

Sub test()

Dim cell As Range
Dim Grng As Range
Dim Icell As Range
Dim blank_cells As Range

With ActiveSheet
Set Grng = .Range("G9, G15, G19, G22, G25, G39")
For Each cell In Grng
Set Icell = .Cells(cell.Row, "I")
If (cell.Value = "No" Or cell.Value = "N/A") And IsEmpty(Icell)
Then
If blank_cells Is Nothing Then
Set blank_cells = Icell
Else
Set blank_cells = Union(blank_cells, Icell)
End If
End If
Next cell
End With
MsgBox "Number of blanks: " & blank_cells.Count & vbCrLf & vbCrLf & _
"Blank cells(s): " & blank_cells.Address
End Sub

--
hth,

Doug
"Sandy" wrote in message
...
Dim c As Variant
Dim i As Variant
Dim numError As Integer
numError = 0
Dim Grng As Range
Dim iVar As Integer
Dim Arng As Variant
iVar = 0

Arng = Array("I9", "I15", "I19", "I22", "I25", "I39")
With ActiveSheet
Set Grng = .Range("G9, G15, G19, G22, G25, G39")
End With
For Each i In Grng.Cells
If i.Text = "No" Or i.Text = "N/A" Then
'Then check to see if indiv cell in I = empty
If Len(Trim(ActiveSheet.Range(Arng(iVar)))) <= 1 Then
numError = numError + 1
End If
iVar = iVar + 1
End If
Next i
MsgBox("Number of blanks: " & numError _
& vbCrLf & vbCrLf & "Blank cells(s): " & vbCrLf & vbCrLf &
CellAddresses



Cell Addresses is the part of the MsgBox I need. If numError is 0, I
have
to loop through cells in G and cells in I and list them in the MsgBox,
five
cells per line with commas between each cell.

I did something similar to this a few days ago and thought I could just
plug
in that code, however, this time, there are two columns to consider --
if
the
G cell is blank it needs to be displayed in the list, or if the G cell
has
"No" or "N/A" then Column I has to be checked for a blank; if it is
blank,
it
has to be listed too.

Any help will be greatly appreciated!!

--
Sandy