Excel Validation & Move

vijaychennai

Board Regular
Joined
Dec 7, 2009
Messages
239
Hello all,

Good day. I have excel in the below format.


Excel 2013/2016
A
1List
2CustomerA
3CustomerB
Sheet1
Cell Formulas
RangeFormula
A1List
A2CustomerA
A3CustomerB


In Sheet 2 I have data in the below format. Need to updated the validation field.


Excel 2013/2016
ABC
1DateCustomerValidation
23/28/2019CustomerA
33/28/2019CustomerB
43/28/2019
53/28/2019Csutomer
63/28/2019CsutomerC
73/28/2019CustomerD
83/28/2019
Sheet2


Answer :


Excel 2013/2016
ABC
1DateCustomerValidation
23/28/2019CustomerAYes
33/28/2019CustomerBYes
43/28/2019Yes
53/28/2019CsutomerNo
63/28/2019CsutomerCNo
73/28/2019CustomerDNo
83/28/2019Yes
Sheet2


Need to move the "No" Values in to sheet 3.


Excel 2013/2016
ABC
1DateCustomerValidation
23/28/2019CsutomerNo
33/28/2019CsutomerCNo
43/28/2019CustomerDNo
Sheet3


Please help me to provide solution in excel VBA.

Regards,
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Try
Code:
Sub dval()
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim ws3 As Worksheet
Dim lr1 As Long
Dim lr2 As Long
Set ws1 = Sheets("Sheet1")
Set ws2 = Sheets("Sheet2")
Set ws3 = Sheets("Sheet3")
lr1 = ws1.Cells(Rows.Count, "A").End(xlUp).Row
lr2 = ws2.Cells(Rows.Count, "A").End(xlUp).Row
lr3 = ws3.Cells(Rows.Count, "A").End(xlUp).Row
For x = 2 To lr2
    If ws2.Cells(x, "B") = "" Or IsNumeric(Application.Match(ws2.Cells(x, "B"), ws1.Range("A2:A" & lr1), 0)) Then
        ws2.Cells(x, "C") = "Yes"
    Else
        ws2.Cells(x, "C") = "No"
    End If
Next x
For y = 2 To lr2
    If ws2.Cells(y, "C") = "No" Then
        ws2.Range("A" & y & ":C" & y).Cut Destination:=ws3.Range("A" & lr3 + 1)
        lr3 = ws3.Cells(Rows.Count, "A").End(xlUp).Row
    End If
Next y
ws2.Range("A2:C" & lr2).SpecialCells(xlBlanks).Delete xlUp
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,335
Messages
6,124,327
Members
449,155
Latest member
ravioli44

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