Sub Открытие_и_копия8()Dim i As IntegerDim iLastRow As LongWorkbooks.Open Filename:="C:\Users\Книга1.xlsm"Set List1 = Workbooks("Книга1.xlsm").Sheets("Лист1")Set List2 = Workbooks("Книга2.xlsm").Sheets("Лист1") iLastRow = List1.Cells(Rows.Count, 1).End(xlUp).Row For i = 1 To iLastRow If Cells(i, 1) Like "*Форум*" Then If List1.Cells(i, 13).Value <> "Отсутствует" Then If Len(List1.Cells(i, 4)) < 25 Then Workbooks("Книга2.xlsm").Activate ActiveWorkbook.Worksheets("Лист1").Select List2.Cells(8, 1) = List1.Cells(i, 4) List2.Cells(9, 1) = List1.Cells(i, 4) List2.Cells(10, 1) = List1.Cells(i, 4) List2.Cells(11, 1) = List1.Cells(i, 4) List2.Cells(12, 1) = List1.Cells(i, 4) List2.Cells(13, 1) = List1.Cells(i, 4) List2.Cells(14, 1) = List1.Cells(i, 4) List2.Cells(15, 1) = List1.Cells(i, 4) List2.Cells(16, 1) = List1.Cells(i, 4) List2.Cells(17, 1) = List1.Cells(i, 4) List2.Cells(18, 1) = List1.Cells(i, 4) List2.Cells(19, 1) = List1.Cells(i, 4) List2.Cells(8, 12) = List1.Cells(i, 4) List2.Cells(9, 12) = List1.Cells(i, 4) List2.Cells(10, 12) = List1.Cells(i, 4) List2.Cells(11, 12) = List1.Cells(i, 4) List2.Cells(12, 12) = List1.Cells(i, 4) List2.Cells(13, 12) = List1.Cells(i, 4) List2.Cells(14, 12) = List1.Cells(i, 4) List2.Cells(15, 12) = List1.Cells(i, 4) List2.Cells(16, 12) = List1.Cells(i, 4) List2.Cells(17, 12) = List1.Cells(i, 4) List2.Cells(18, 12) = List1.Cells(i, 4) List2.Cells(19, 12) = List1.Cells(i, 4) End If End If End If Next i Workbooks("Книга1.xlsm").Close FalseEnd Sub
iLastRow = List1.Cells(Rows.Count, 1).End(xlUp).Row
iLastRow = List1.Cells(List1.Rows.Count, 1).End(xlUp).Row
Sub Открытие_и_копия3() Dim i As Integer Dim j As Integer Dim iLastRow As Long Workbooks.Open Filename:="C:\Users\Книга1.xlsm" Set List1 = Workbooks("Книга1.xlsm").Sheets("Лист1") Set List2 = Workbooks("Книга2.xlsm").Sheets("Лист1") iLastRow = List1.Cells(Rows.Count, 1).End(xlUp).Row For i = 1 To iLastRow For j = 8 To 19 If Cells(i, 1) Like "*Форум*" Then If List1.Cells(i, 13).Value <> "Отсутствует" Then If Len(List1.Cells(i, 4)) < 25 Then Workbooks("Книга2.xlsm").Activate ActiveWorkbook.Worksheets("Лист1").Select List2.Cells(j, 1) = List1.Cells(i, 4) List2.Cells(j, 12) = List1.Cells(i, 4) End If End If End If Next j Next i Workbooks("Книга1.xlsm").Close False End Sub
List2.Cells(j, 1) = List1.Cells(i, 4)List2.Cells(j, 12) = List1.Cells(i, 4)
Workbooks("Книга2.xlsm").Activate ActiveWorkbook.Worksheets("Лист1").Select
If LCase(List1.Cells(i, 1).Value) Like "*форум*" Then If LCase(List1.Cells(i, 13).Value) <> "отсутствует" Then If Len(List1.Cells(i, 4)) < 25 Then
Sub Открытие_и_копия3() Dim i As Long, j As Long Dim iLastRow As Long, llastr_2 As Long Workbooks.Open Filename:="C:\Users\Книга1.xlsm" Set List1 = Workbooks("Книга1.xlsm").Sheets("Лист1") Set List2 = Workbooks("Книга2.xlsm").Sheets("Лист1") iLastRow = List1.Cells(List1.Rows.Count, 1).End(xlUp).Row For i = 1 To iLastRow If LCase(List1.Cells(i, 1).Value) Like "*форум*" Then If LCase(List1.Cells(i, 13).Value) <> "отсутствует" Then If Len(List1.Cells(i, 4)) < 25 Then llastr_2 = List2.Cells(List2.Rows.Count, 1).End(xlUp).Row For j = 1 To 11 List2.Cells(llastr_2 + j, 1) = List1.Cells(i, 4) List2.Cells(llastr_2 + j, 12) = List1.Cells(i, 4) Next j End If End If End If Next i Workbooks("Книга1.xlsm").Close FalseEnd Sub
For j = 1 To 11 List2.Cells(llastr_2 + j, 1) = List1.Cells(i, 4) List2.Cells(llastr_2 + j, 12) = List1.Cells(i, 4) Next j
List2.Cells(llastr_2 + 1, 1) = List1.Cells(i, 4)List2.Cells(llastr_2 + 1, 2) = List1.Cells(i, 4)
Sub Открытие_и_копия3() Dim i As Long, j As Long Dim iLastRow As Long, llastr_2 As Long Workbooks.Open Filename:="C:\Users\Администратор\Desktop\Пример\Книга1.xlsm" Set List1 = Workbooks("Книга1.xlsm").Sheets("Лист1") Set List2 = Workbooks("Книга2.xlsm").Sheets("Лист1") iLastRow = List1.Cells(List1.Rows.Count, 1).End(xlUp).Row For i = 2 To iLastRow If LCase(List1.Cells(i, 1).Value) Like "*форум*" Then If LCase(List1.Cells(i, 4).Value) <> "отсутствует" Then If Len(List1.Cells(i, 3)) < 25 Then llastr_2 = List2.Cells(List2.Rows.Count, 1).End(xlUp).Row List2.Cells(llastr_2 + 1, 1).Value = List1.Cells(i, 2).Value List2.Cells(llastr_2 + 1, 2).Value = List1.Cells(i, 2).Value End If End If End If Next i Workbooks("Книга1.xlsm").Close FalseEnd Sub
Sub Открытие_и_копия3() Dim i As Long, j As Long Dim iLastRow As Long, llastr_2 As Long, lres_col As Long Workbooks.Open Filename:="C:\Users\Администратор\Desktop\Пример\Книга1.xlsm" Set List1 = Workbooks("Книга1.xlsm").Sheets("Лист1") Set List2 = Workbooks("Книга2.xlsm").Sheets("Лист1") iLastRow = List1.Cells(List1.Rows.Count, 1).End(xlUp).Row lres_col = 1 For i = 2 To iLastRow If LCase(List1.Cells(i, 1).Value) Like "*форум*" Then If LCase(List1.Cells(i, 4).Value) <> "отсутствует" Then If Len(List1.Cells(i, 3)) < 25 Then llastr_2 = List2.Cells(20, lres_col).End(xlUp).Row If llastr_2 < 7 Then lres_col = lres_col + 1 llastr_2 = 7 End If List2.Cells(llastr_2 + 1, lres_col).Value = List1.Cells(i, 2).Value End If End If End If Next i Workbooks("Книга1.xlsm").Close FalseEnd Sub