VBA; String variable; If Statement; Empty cell

Sandcrab

New Member
Joined
Jan 22, 2015
Messages
2
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
 
Last edited:

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Apologies: Edit to the Above.

Reference to "Form" is to be removed in it's entirety and replaced with "Panel Search Engine"
 
Upvote 0

Forum statistics

Threads
1,226,693
Messages
6,192,471
Members
453,726
Latest member
JoeH57

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top