Имя пользователя:
Пароль:  
Помощь | Регистрация | Забыли пароль?  

Показать сообщение отдельно

Аватара для hasherfrog

Старый параноик


Сообщения: 2423
Благодарности: 85

Профиль | Отправить PM | Цитировать


Начерно, без изысков:
Код: Выделить весь код
Sub Macros1()

strTarget$ = "la-la-la"    ' <----- Place word (substring) to find here
nTotal = Rows.Count        ' <----- Place rows range here (1 to nTotal)

strTarget1$ = strTarget$ + " "
strTarget2$ = " " + strTarget$
strTarget3$ = " " + strTarget$ + " "

For I = 1 To nTotal ' don't use Rows.Count here

again:
bFound = 0

For J = 1 To Columns.Count
strThis$ = Cells(I, J)
If strThis$ = strTarget$ Then bFound = 1
If InStr(strThis$, strTarget1$) Then bFound = 1
If InStr(strThis$, strTarget2$) Then bFound = 1
If InStr(strThis$, strTarget3$) Then bFound = 1
Next J

If bFound = 0 Then GoTo notfound
Rows(I).Select
Selection.Delete Shift:=xlUp
GoTo again

notfound:
Next I

End Sub

Отправлено: 11:00, 30-09-2005 | #2