< návrat zpět
MS Excel
Téma: makro pro. DEL. RADKU
Zaslal/a jan99 8.7.2011 14:54
Ahoj, nasel jsem na netu makro pro odstraneni radku podle klicoveho slova ale nevim jak to upravit.
- potreboval bych aby to odstranilo i napr. 44asdds_slovo. Ted to najde jen to osamocene slovo v bunce ale pokud je to jeste spojeno s necim tak to nenajde.
- a jeste bych potreboval nejak zapsat podminku ".. NEBO slovo2"
DIKY!
****************************************
Sub DeleteSpecifiedRows()
Dim lngRow As Long, MyWord As String
MyWord = "slovo"
For lngRow = 65536 To 1 Step -1
If UCase(Cells(lngRow, "A").Value) = UCase(MyWord) Then Rows(lngRow).delete
Next lngRow
End Sub
Poki(11.7.2011 16:30)#005472 Nechtelo se mi moc premyslet, tak je ten kod mozna zbytecne dlouhej, ale mohl by fungovat.
Za promenne Slovo1 a Slovo2 (v kodu) si dosadte hledana slova.
Sub smaz_radek()
Dim Radek As Long
Dim i As Long
Dim Slovo1 As String
Dim Slovo2 As String
Dim rSlovo1 As Long
Dim rSlovo2 As Long
Slovo1 = "jirka"
Slovo2 = "david"
Radek = Cells(65000, 1).End(xlUp).Row
For i = Radek To 2 Step -1
Err.Number = 0
On Error Resume Next
rSlovo1 = Application.WorksheetFunction.Search(Slovo1, Cells(i, 1).Value)
If Err.Number <> 1004 Then
Rows(i).Delete
GoTo dalsi
End If
Err.Number = 0
rSlovo2 = Application.WorksheetFunction.Search(Slovo2, Cells(i, 1).Value)
If Err.Number <> 1004 Then
Rows(i).Delete
GoTo dalsi
End If
dalsi:
On Error GoTo 0
Next i
End Subcitovat