Hi all - i have tried to adapt the following code but it seems to not be working, hoping someone could provide a solution.
using a macro to call userform1
command button in user form is meant to copy the value in text box to LOG sheet (this works fine)
but then i wanted to call another macro to check Columns A and B.... Col A for the number that was in the text box, and Col B for the number 1.
if BOTH conditions exist give msgbox and exit sub, if not, continue.
the problem i have is that regardless of conditions the msgbox appears. and i am assuming it is calling the Call Submit macro.... so i don't think my check is being done right...
TIA
using a macro to call userform1
command button in user form is meant to copy the value in text box to LOG sheet (this works fine)
but then i wanted to call another macro to check Columns A and B.... Col A for the number that was in the text box, and Col B for the number 1.
if BOTH conditions exist give msgbox and exit sub, if not, continue.
the problem i have is that regardless of conditions the msgbox appears. and i am assuming it is calling the Call Submit macro.... so i don't think my check is being done right...
Code:
Sub cardcheck()
Dim rowCount As Long, i As Long
Dim ws As Worksheet: Set ws = ThisWorkbook.Sheets("LOG")
Dim FindString As String
FindString = Worksheets("LOG").Cells(1, 7).Value
rowCount = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row
Application.ScreenUpdating = False
'i refers to row number
For i = 1 To rowCount
If ws.Range("A" & i) = FindString And ws.Range("b" & i) = 1 Then
MsgBox "This card number already used in survey, response not submitted."
Worksheets("Survey").Activate
Exit Sub
Else
Call submit
End If
Next i
End Sub
TIA