excel macro to remove specific columns and rows + remove duplicate
Hello,
New forum user, I was a bit out of resources on google...so let's see if someone could maybe help me.
I started something with a friend to sort our list and need your help on the below code, as is it not working like a charm I need you help.
Actually we compiled several sources and try to make it work:
PHP Code:
Sub GetFiles()
Dim sThisFilePath As String
''''''''''''''''''''''''''''''''find keywords and delete rows...'''''''''''''''''''''''
'Workbooks(1).Activate
mycount = Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To mycount
For j = 1 To 9
If InStr(Cells(i, j).Value, "keyword 1") > 0 Then
Cells(i, 1).EntireRow.Delete
End If
If InStr(Cells(i, j).Value, "keyword 2") > 0 Then
Cells(i, 1).EntireRow.Delete
End If
On Error Resume Next
Next j
Next i
'''''''''''''''' new updates'''''''''''''''''''''''''''''''''
mycount = Cells(Rows.Count, 1).End(xlUp).Row
'MsgBox mycount
For i = 2 To mycount
j = 9
If InStr(Cells(i, 9).Value, "(") > 0 Or InStr(Cells(i, 9).Value, ")") > 0 Then
text1 = Cells(i, 9).Value
r = InStr(text1, "(")
s = InStr(text1, ")")
MsgBox r
MsgBox s
MsgBox text1
text2 = Mid(text1, r + 1, s - r - 1)
MsgBox text2
Cells(i, j).Value = text2
End If
If InStr(Cells(i, 9).Value, "qq.com") > 0 Then
Cells(i, 1).EntireRow.Delete
End If
If Len(Trim(Cells(i, 9).Value)) = 0 Then
Cells(i, 1).EntireRow.Delete
End If
If InStr(Cells(i, 9).Value, "@") = 0 Then
Cells(i, 1).EntireRow.Delete
End If
text1 = Trim(Cells(i, 9).Value)
If Len(text1) < 4 Then
Cells(i, 1).EntireRow.Delete
End If
'If Left(Cells(i, 9).Value, 1) = "(" Then
'Cells(i, 9).Value = Mid(Cells(i, 9).Value, 2, Len(Cells(i, 9).Value) - 2)
'End If
'If Left(Cells(i, 9).Value, 3) = " " Then
'Cells(i, 9).EntireRow.Delete
'End If
Cells(i, 9).Select
If IsEmpty(ActiveCell) Then
Cells(i, 9).EntireRow.Delete
End If
Next i
''''''''''''''''''''''''''''Remove duplicates '''''''''''''''''''''''''''''''''''''''''
mycount = Cells(Rows.Count, 1).End(xlUp).Row
'MsgBox mycount
For i = 2 To mycount
text1 = Trim(Cells(i, 9).Value)
For j = i + 1 To mycount
If Trim(Cells(j, 9).Value) = text1 Then
Cells(j, 9).EntireRow.Delete
mycount = mycount - 1
End If
Next j
Next i
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'For i = 2 To sheetscount
'Workbooks(i).Close
'Next i
Bookmarks