VBA : Need to show message(MsgBox) of Only Either one of the Column should be entered when clicked on validate button

Stranger8421

New Member
Joined
Jun 30, 2022
Messages
23
Office Version
  1. 365
Hello Guys,

Need help from you guys.

Below This sheet: When we clicked on the Validate Button. It should check for the Order Id (B column), Only Normal (C column) or Only Premium (D column) should be entered. If Both C and D column is entered, The message should be shown "Please enter either One of the columns". Note : for Order Id -1233. Normal and Premium should not enter till range C3 : D4 , only C2 OR D2 should be entered. If entered range is C3:D4 message should be shown "Please enter Normal or premium only in Order Line"
and one boolean should be there. and also one boolean should be there. All entered data is correct means true else false.
NameOrder IdNormalPremiumadd-on
ABC
1233​
12​
32​
23​
bbc
3223​
45​
32​
ccc
3333​
23​

Final Correct user input should be given in below sheet: Here see For one Order - only entered is Normal or premium.
NameOrder IdNormalPremiumadd-on
ABC
1233​
23​
12​
32​
23​
bbc
3223​
22​
45​
32​
ccc
3333​
12​
23​

And I tried till the Range selection for the Order.

<VBA Code>
Private Sub validate_Click()

Dim i As Long, j As Long, lastrow As Long, rng As Long

lastrow = Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To lastrow
If Cells(i, "B") <> "" Then

rng = Cells(i, "B").End(xlDown).Row - 1

If Cells(i + 1, "B") <> "" Then rng = i
'code should enter here
End If
Next i

End Sub

</VBA COde>

Thanks for reading my thread.
Regards,
Joe
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

Forum statistics

Threads
1,215,228
Messages
6,123,747
Members
449,118
Latest member
kingjet

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