Dear Forum Members,
I am hoping you can assist a newbie here.
The following is required from my VBA code:
A cell input is made in the "Form" sheet and compared with a cell in the "Formdata" sheet. If the cells are different then a MsgBox is displayed with a warning and the cell is deleted. However, in the first instance of selecting an input from the "Form", the empty cell from "Formdata" is matched against the input. Whilst I'm assuming this is technically correct (empty cell <> forminput), the Form input is saying "no match" against an empty cell. I dont want the IF statement to compare against empty cells only from data input into the cells, otherwise the program does not progress. Any ideas?
Sub CopyInfo1()
Dim n As String
Dim x As String
Dim iRet As Integer
n = Sheets("Formdata").Cells(Rows.Count, "A").End(xlUp).row + 1
Sheets("Panel Search Engine").Range("B29:D29").Copy
Sheets("Formdata").Range("A" + n).PasteSpecial xlPasteValues
Sheets("Panel Search Engine").Range("B31:D31").Copy
Sheets("Formdata").Range("D" + n).PasteSpecial xlPasteValues
Application.CutCopyMode = False
iRet = MsgBox("Add another Labour Category?", vbYesNo + vbQuestion, "Add another Labour Category")
If iRet = vbNo Then Sheets("FORM").Select Else 'continue searching
x = Sheets("Panel Search Engine").Range("D6")
If x <> Sheets("Formdata").Range("A2") Then MsgBox "Warning! Different Supplier Selected! Remove from Form", vbExclamation, "WARNING!"
If x <> Sheets("Formdata").Range("A2") Then Sheets("Formdata").Range("D" + n).EntireRow.Delete
End Sub
I am hoping you can assist a newbie here.
The following is required from my VBA code:
A cell input is made in the "Form" sheet and compared with a cell in the "Formdata" sheet. If the cells are different then a MsgBox is displayed with a warning and the cell is deleted. However, in the first instance of selecting an input from the "Form", the empty cell from "Formdata" is matched against the input. Whilst I'm assuming this is technically correct (empty cell <> forminput), the Form input is saying "no match" against an empty cell. I dont want the IF statement to compare against empty cells only from data input into the cells, otherwise the program does not progress. Any ideas?
Sub CopyInfo1()
Dim n As String
Dim x As String
Dim iRet As Integer
n = Sheets("Formdata").Cells(Rows.Count, "A").End(xlUp).row + 1
Sheets("Panel Search Engine").Range("B29:D29").Copy
Sheets("Formdata").Range("A" + n).PasteSpecial xlPasteValues
Sheets("Panel Search Engine").Range("B31:D31").Copy
Sheets("Formdata").Range("D" + n).PasteSpecial xlPasteValues
Application.CutCopyMode = False
iRet = MsgBox("Add another Labour Category?", vbYesNo + vbQuestion, "Add another Labour Category")
If iRet = vbNo Then Sheets("FORM").Select Else 'continue searching
x = Sheets("Panel Search Engine").Range("D6")
If x <> Sheets("Formdata").Range("A2") Then MsgBox "Warning! Different Supplier Selected! Remove from Form", vbExclamation, "WARNING!"
If x <> Sheets("Formdata").Range("A2") Then Sheets("Formdata").Range("D" + n).EntireRow.Delete
End Sub
Last edited: