I have just post a question last week. The question is about finding a the missing cell in a list. It is the post link Button click find empty cell
Base on the previous question i would like to add on some new function.
Red column is mandatory field and green is optional field.
I would like to add a new column and create a button that could generate all the mandatory fields to a new worksheet.
As you can see, there are a new column and a new button that was created. Now, I would like to use the "generate button" to generate all the mandatory(Red) fields into a new worksheet call "important". However, it is I have a condition rely on the column K to decide which row of data i will generate. If col K is YES than it will generate that row of data if col K is No then I will not generate that row to the new sheet.
My problem is how can i generate a new worksheet and fetch those mandatory fields to a new worksheet with yes or no condition in col K Thank you
It is my code :
Private Sub CommandButton2_Click()
Dim rng As Range
Dim selected As Range
Dim newws As Worksheet
Dim yesno As Range
Dim lastrow As Long
Dim justify As Boolean
lastrow = Range("B3").End(xlDown).Row
Set rng = Range("B3:J" & lastrow)
Set yesno = Range("K3:K" & lastrow)
Worksheets("Important").Add after:=Sheets(Worksheets.Count)
Set wks = ActiveSheet
For Each selected In rng
If rng.Cells.Value = "Yes" Then
justify = True
Worksheets("Important").Copy
Else
If rng.Cells.Value = "No" Then
justify = False
Set newws = Nothing
End If
End If
Next
End Sub