View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default Validation Testing through list

isnull is pretty useless for testing whether a cell contains a value.

Instead use
isempty instead of isnull.

--
Regards,
Tom Ogilvy


"Matt Pierringer" wrote:

On Mar 12, 8:01 am, Tom Ogilvy
wrote:
You post is pretty confusing. Perhaps you can find something he

Dim rng as range, cell as Range, bFound as Boolean
set rng = Range(cells(2,1),cells(rows.count,1).End(xlup)
bFound = False
for each cell in rng
If Application.Countif(range("MaterialNumbers"),cell) 0 then
bFound = True
exit for
end if
Next
if bfound then exit sub
set cell = rng(rng.count + 1)
Cell.Offset(0, 1) = InputBox("Enter data", "Column B")
Cell.Offset(0, 2) = InputBox("Enter data", "Column C")
Cell.Offset(0, 3) = InputBox("Enter data", "Column D")
Cell.Offset(0, 4) = InputBox("Enter data", "Column E")
Cell.Offset(0, 5) = InputBox("Enter data", "Column F")
Cell.Offset(0, 6) = InputBox("Enter data", "Column G")
Cell.Offset(0, 7) = InputBox("Enter data", "Column H")

--
Regards,
Tom Ogilvy

"Matt Pierringer" wrote:
My goal is to be able to have my loop go through a list and check if
any cell in column a is equal to the list, if not it must make a
prompt for the next 7 cells.


If ActiveCell.Value 1 Then 'Not sure how to make this only column 1
For Each ce In Range("L1:L500" & Cells(Rows.Count, 1).End(xlUp).Row)
'Not sure how to use my named range "Material Numbers" instead of
"L1:L500"
ce.Offset(0, 1) = WorksheetFunction.CountIf(Range("L1:L500"),
ce.Value)
If ActiveCell.Value = ce.Value Then
ActiveCell.Offset(0, 1) = InputBox("Enter data", "Column B")
ActiveCell.Offset(0, 2) = InputBox("Enter data", "Column C")
ActiveCell.Offset(0, 3) = InputBox("Enter data", "Column D")
ActiveCell.Offset(0, 4) = InputBox("Enter data", "Column E")
ActiveCell.Offset(0, 5) = InputBox("Enter data", "Column F")
ActiveCell.Offset(0, 6) = InputBox("Enter data", "Column G")
ActiveCell.Offset(0, 7) = InputBox("Enter data", "Column H")
Exit Sub
Else
Next ce
End If


Thanks any help is appreciated
-Matt


Thanks Tom, I am sorry about the confusing post... I wasn't exactly
sure how to word it. You got very close for the information I gave
you. The problem I am having now is when it the input box shows up it
will enter the value in the cell, and then I click Ok, but the same
input box pops up. I need to be able to test for a null value before
that pops up which I thought the following code would do the trick:

Dim rng As Range, cell As Range, bFound As Boolean
Set rng = Range(Cells(2, 1), Cells(Rows.Count, 1).End(xlUp))
bFound = False
For Each cell In rng
If Application.CountIf(Range("MaterialNumbers"), cell) 0 Then
bFound = True
Exit For
End If
Next
If bFound Then Exit Sub
Set cell = rng(rng.Count + 1)
If IsNull(cell.Offset(-1, 1)) = True Then
cell.Offset(-1, 1) = InputBox("Enter data", "Column B")
End If
If IsNull(cell.Offset(-1, 2)) Then
cell.Offset(-1, 2) = InputBox("Enter data", "Column C")
End If
If IsNull(cell.Offset(-1, 3)) Then
cell.Offset(-1, 3) = InputBox("Enter data", "Column D")
End If
If IsNull(cell.Offset(-1, 4)) Then
cell.Offset(-1, 4) = InputBox("Enter data", "Column E")
End If
If IsNull(cell.Offset(-1, 5)) Then
cell.Offset(-1, 5) = InputBox("Enter data", "Column F")
End If
If IsNull(cell.Offset(-1, 6)) Then
cell.Offset(-1, 6) = InputBox("Enter data", "Column G")
End If
If IsNull(cell.Offset(-1, 7)) Then
cell.Offset(-1, 7) = InputBox("Enter data", "Column H")
End If


The code doesn't prompt any input boxes even though the cell does not
contain anything, also I am sure there is an easier way that doing all
of the If statements