Another approach using dictionary [code] Private Sub UserForm_Initialize() Dim arr As Variant arr = GetDistinct(Range("A1:A" & Cells(Rows.Count, 1).End(xlUp).Row)) ListBox1.List =...
Thanks a lot PNRao for this great solution Another approach using collection [code] Private Sub UserForm_Initialize() Dim ws As Worksheet...
Thanks vaali... this is the data sheet1 data EID NAME PAY PayDay 14123 Joe1 $1,234.00 29-Jun-17 14124 Joe2...
HI, Here is the required macro to search a field and if value found copy the whole row into another...
I found a solution like this :Records in between two specific dates easily can be filtered using drop-down lists ....
I found a solution as follows: Watch the video to see how it's done and download example file : https://youtu.be/SZduAoOtiS0
I have sorted the above problem. Code is given below... [code] Sub seperate() Call CleanSheets MsgBox "1 of 10 Cleaning...
In one of my, worksheets I have one of the fields named “Product”.
If the calculated value is 1, I want to delete that line and the two above it.
If the calculated value is 0, then I want to delete that line only.
How do I do it with VBA?
Here is the solution to resolve your query.
ProductColumn = 1 'Specify Which column has 'Product' as header
LastRow = 10 'Chnage the last row value
For i = LastRow To 2 Step -1
If .Cells(i, ProductColumn) = 0 Then
ElseIf .Cells(i, ProductColumn) = 1 Then
If i = 2 Then
.Rows(i - 2 & ":" & i).Delete shift:=xlUp
i = i - 2
I don’t know if this is right … the column “Product” is in worksheet “MbrsDetChanged”
comes up with an error
Runtime error 1004
Method range of object _Global fail
For i = LastRow To firstrow Step -1
If Range(i, "Product") = 0 Then
ElseIf Range(i, "Product") = 1 Then
Rows(i - 2 & ":" & i).Delete shift:=xlUp
Please share using the share button above.
If you found the answer is best answer for your question, Please mark as 'best answer' by clicking on the right tick mark icon at the left side of the answer.
Found the answer useful and wants to credit the user, then vote the answer (vote up).