GalinaS
Дата: Вторник, 28.02.2023, 11:31 |
Сообщение № 1
Группа: Пользователи
Ранг: Прохожий
Сообщений: 2
Репутация:
0
±
Замечаний:
0% ±
Помогите, пожалуйста. Записывала макрос именно с помощью записи макроса. При выполнении макрос выдает ошибку Run-time error '1004': Метод Autofill из класса Range завершен неверно. Ругается на строчку Selection.AutoFill Destination:=Range("I2:I9806") [vba]Код
Cells.Select Selection.Replace What:="0", Replacement:="", LookAt:=xlWhole, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Selection.Replace What:="н/с", Replacement:="", LookAt:=xlWhole, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False ActiveWindow.ScrollColumn = 33 ActiveWindow.ScrollColumn = 26 ActiveWindow.SmallScroll Down:=57 ActiveWindow.ScrollRow = 2915 Selection.Replace What:="00.01.1900", Replacement:="", LookAt:=xlWhole, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False ActiveWindow.ScrollRow = 1 Range("AJ7").Select ActiveWindow.ScrollColumn = 1 ActiveWindow.ScrollColumn = 20 Range("Z2").Select ActiveWindow.ScrollColumn = 1 Range("D2").Select ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-2],'коды ТНВЭД'!R2C1:R3911C2,2,0)" Selection.AutoFill Destination:=Range("D2:D10806") Range("D2:D10806").Select Range("P2").Select ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-1],страны!R2C1:R256C2,2,0)" Selection.AutoFill Destination:=Range("P2:P10806") Range("P2:P10806").Select ActiveWindow.ScrollColumn = 12 ActiveWindow.ScrollColumn = 29 Range("AL2").Select ActiveCell.FormulaR1C1 = "=IF(RC[-1]=0,""С"")" Range("AL2").Select Selection.ClearContents Range("AL2").Select ActiveCell.FormulaR1C1 = "=IF(RC[-1]=0,""С"",0)" Columns("AK:AK").Select Selection.Replace What:="0", Replacement:="", LookAt:=xlWhole, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Range("AL2").Select ActiveCell.FormulaR1C1 = "=IF(RC[-1]=0,""С"",0)" Range("AL2").Select ActiveCell.FormulaR1C1 = "=IF(RC[-1]>0,0,""С"")" Range("AK2").Select ActiveCell.FormulaR1C1 = "1/0/1900" Range("AK2").Select Selection.Copy Range("AL2").Select Application.CutCopyMode = False ActiveCell.FormulaR1C1 = "=IF(RC[-1]>0,0,""С"")" Range("AK2").Select Selection.ClearContents Range("AL2").Select Selection.ClearContents Range("AL2").Select ActiveCell.FormulaR1C1 = "=IF(RC[-3]=0,""С"")" Selection.AutoFill Destination:=Range("AL2:AL10806") Range("AL2:AL10806").Select ActiveCell.FormulaR1C1 = "=IF(RC[-3]=0,""С"",""0"")" Range("AL2").Select Selection.AutoFill Destination:=Range("AL2:AL10806") Range("AL2:AL10806").Select Range("AL15").Select ActiveWindow.ScrollColumn = 1 Range("A2").Select ActiveCell.FormulaR1C1 = "=1" Range("V2").Select ActiveCell.FormulaR1C1 = "=1" Range("A3").Select ActiveCell.FormulaR1C1 = "=IF(RC[17]=0,R[-1]C,R[-1]C+1)" Selection.AutoFill Destination:=Range("A3:A10806") Range("A3:A10806").Select Range("V3").Select ActiveCell.FormulaR1C1 = "=IF(RC[-4]=0,R[-1]C+1,1)" Selection.AutoFill Destination:=Range("V3:V10806") Range("V3:V10806").Select ActiveWindow.ScrollRow = 1 Range("Z2:AA2").Select Selection.AutoFill Destination:=Range("Z2:AA10806") Range("Z2:AA703").Select Range("AF2").Select Selection.AutoFill Destination:=Range("AF2:AF10806") Range("AF2:AF703").Select ActiveWindow.SmallScroll Down:=276 ActiveWindow.ScrollRow = 647 ActiveWindow.SmallScroll Down:=45 ActiveWindow.ScrollRow = 7717 ActiveWindow.ScrollRow = 1 ActiveWindow.SmallScroll ToRight:=11 Range("AM2").Select ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-14],ТРОИС!R1C1:R2138C5,2,0)" Range("AN2").Select ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-15],ТРОИС!R1C1:R2126C5,3,0)" Range("AO2").Select ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-16],ТРОИС!R2C1:R2412C4,4,0)" Range("AM2:AO2").Select Selection.AutoFill Destination:=Range("AM2:AO10806") Range("AM2:AO703").Select ActiveWindow.ScrollRow = 2190 ActiveWindow.SmallScroll Down:=-60 ActiveWindow.ScrollRow = 647 ActiveWindow.SmallScroll Down:=-114 ActiveWindow.ScrollRow = 1 Range("AI2").Select ActiveWindow.ScrollColumn = 2 Columns("AM:AO").Select ActiveWorkbook.Save Columns("AM:AO").Select Selection.Copy Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _ xlNone, SkipBlanks:=False, Transpose:=False Selection.Replace What:="#?/?", Replacement:="", LookAt:=xlWhole, _ SearchOrder:=xlByColumns, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Range("AN10").Select Range("G3").Select ActiveCell.FormulaR1C1 = "=IF(RC[-6]=R[-1]C[-6],,1)" Selection.AutoFill Destination:=Range("G3:G10806") Range("G3:G10806").Select Range("H3").Select ActiveCell.FormulaR1C1 = "=IF(RC[-7]=R[-1]C[-7],,""PK"")" Selection.AutoFill Destination:=Range("H3:H10806") Range("H3:H10806").Select Columns("G:H").Select Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Selection.Replace What:="0", Replacement:="", LookAt:=xlWhole, _ SearchOrder:=xlByColumns, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Range("AH2").Select Application.CutCopyMode = False ActiveCell.FormulaR1C1 = "=IF(RC[1]=0,,""'01401"")" ActiveCell.FormulaR1C1 = "=IF(RC[1]=0,,""01401"")" Range("AH2").Select Selection.AutoFill Destination:=Range("AH2:AH10806") Range("AH2:AH10806").Select Columns("AH:AH").Select Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Selection.Replace What:="0", Replacement:="", LookAt:=xlWhole, _ SearchOrder:=xlByColumns, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Columns("AL:AL").Select Selection.Replace What:="0", Replacement:="", LookAt:=xlWhole, _ SearchOrder:=xlByColumns, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Application.CutCopyMode = False Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Selection.Find(What:="0", After:=ActiveCell, LookIn:=xlFormulas, LookAt _ :=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase _ :=False, SearchFormat:=False).Activate Selection.Replace What:="0", Replacement:="", LookAt:=xlWhole, _ SearchOrder:=xlByColumns, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Range("AI11").Select ActiveWindow.SmallScroll Down:=147 ActiveWindow.ScrollRow = 7950 ActiveWindow.SmallScroll Down:=-18 ActiveWindow.ScrollRow = 1 Range("AK6").Select ActiveWindow.ScrollColumn = 1 Application.CutCopyMode = False ActiveCell.FormulaR1C1 = "=IF(RC[-8]=R[-1]C[-8],"""",RC[-4])" Selection.AutoFill Destination:=Range("I2:I10806") Range("I2:I10806").Select End Sub
[/vba] При чем, если вот эту часть вынести в отдельный макрос, то ошибка не выскакивает [vba]Код
Application.CutCopyMode = False ActiveCell.FormulaR1C1 = "=IF(RC[-8]=R[-1]C[-8],"""",RC[-4])" Selection.AutoFill Destination:=Range("I2:I10806") Range("I2:I10806").Select
[/vba]
Помогите, пожалуйста. Записывала макрос именно с помощью записи макроса. При выполнении макрос выдает ошибку Run-time error '1004': Метод Autofill из класса Range завершен неверно. Ругается на строчку Selection.AutoFill Destination:=Range("I2:I9806") [vba]Код
Cells.Select Selection.Replace What:="0", Replacement:="", LookAt:=xlWhole, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Selection.Replace What:="н/с", Replacement:="", LookAt:=xlWhole, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False ActiveWindow.ScrollColumn = 33 ActiveWindow.ScrollColumn = 26 ActiveWindow.SmallScroll Down:=57 ActiveWindow.ScrollRow = 2915 Selection.Replace What:="00.01.1900", Replacement:="", LookAt:=xlWhole, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False ActiveWindow.ScrollRow = 1 Range("AJ7").Select ActiveWindow.ScrollColumn = 1 ActiveWindow.ScrollColumn = 20 Range("Z2").Select ActiveWindow.ScrollColumn = 1 Range("D2").Select ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-2],'коды ТНВЭД'!R2C1:R3911C2,2,0)" Selection.AutoFill Destination:=Range("D2:D10806") Range("D2:D10806").Select Range("P2").Select ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-1],страны!R2C1:R256C2,2,0)" Selection.AutoFill Destination:=Range("P2:P10806") Range("P2:P10806").Select ActiveWindow.ScrollColumn = 12 ActiveWindow.ScrollColumn = 29 Range("AL2").Select ActiveCell.FormulaR1C1 = "=IF(RC[-1]=0,""С"")" Range("AL2").Select Selection.ClearContents Range("AL2").Select ActiveCell.FormulaR1C1 = "=IF(RC[-1]=0,""С"",0)" Columns("AK:AK").Select Selection.Replace What:="0", Replacement:="", LookAt:=xlWhole, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Range("AL2").Select ActiveCell.FormulaR1C1 = "=IF(RC[-1]=0,""С"",0)" Range("AL2").Select ActiveCell.FormulaR1C1 = "=IF(RC[-1]>0,0,""С"")" Range("AK2").Select ActiveCell.FormulaR1C1 = "1/0/1900" Range("AK2").Select Selection.Copy Range("AL2").Select Application.CutCopyMode = False ActiveCell.FormulaR1C1 = "=IF(RC[-1]>0,0,""С"")" Range("AK2").Select Selection.ClearContents Range("AL2").Select Selection.ClearContents Range("AL2").Select ActiveCell.FormulaR1C1 = "=IF(RC[-3]=0,""С"")" Selection.AutoFill Destination:=Range("AL2:AL10806") Range("AL2:AL10806").Select ActiveCell.FormulaR1C1 = "=IF(RC[-3]=0,""С"",""0"")" Range("AL2").Select Selection.AutoFill Destination:=Range("AL2:AL10806") Range("AL2:AL10806").Select Range("AL15").Select ActiveWindow.ScrollColumn = 1 Range("A2").Select ActiveCell.FormulaR1C1 = "=1" Range("V2").Select ActiveCell.FormulaR1C1 = "=1" Range("A3").Select ActiveCell.FormulaR1C1 = "=IF(RC[17]=0,R[-1]C,R[-1]C+1)" Selection.AutoFill Destination:=Range("A3:A10806") Range("A3:A10806").Select Range("V3").Select ActiveCell.FormulaR1C1 = "=IF(RC[-4]=0,R[-1]C+1,1)" Selection.AutoFill Destination:=Range("V3:V10806") Range("V3:V10806").Select ActiveWindow.ScrollRow = 1 Range("Z2:AA2").Select Selection.AutoFill Destination:=Range("Z2:AA10806") Range("Z2:AA703").Select Range("AF2").Select Selection.AutoFill Destination:=Range("AF2:AF10806") Range("AF2:AF703").Select ActiveWindow.SmallScroll Down:=276 ActiveWindow.ScrollRow = 647 ActiveWindow.SmallScroll Down:=45 ActiveWindow.ScrollRow = 7717 ActiveWindow.ScrollRow = 1 ActiveWindow.SmallScroll ToRight:=11 Range("AM2").Select ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-14],ТРОИС!R1C1:R2138C5,2,0)" Range("AN2").Select ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-15],ТРОИС!R1C1:R2126C5,3,0)" Range("AO2").Select ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-16],ТРОИС!R2C1:R2412C4,4,0)" Range("AM2:AO2").Select Selection.AutoFill Destination:=Range("AM2:AO10806") Range("AM2:AO703").Select ActiveWindow.ScrollRow = 2190 ActiveWindow.SmallScroll Down:=-60 ActiveWindow.ScrollRow = 647 ActiveWindow.SmallScroll Down:=-114 ActiveWindow.ScrollRow = 1 Range("AI2").Select ActiveWindow.ScrollColumn = 2 Columns("AM:AO").Select ActiveWorkbook.Save Columns("AM:AO").Select Selection.Copy Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _ xlNone, SkipBlanks:=False, Transpose:=False Selection.Replace What:="#?/?", Replacement:="", LookAt:=xlWhole, _ SearchOrder:=xlByColumns, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Range("AN10").Select Range("G3").Select ActiveCell.FormulaR1C1 = "=IF(RC[-6]=R[-1]C[-6],,1)" Selection.AutoFill Destination:=Range("G3:G10806") Range("G3:G10806").Select Range("H3").Select ActiveCell.FormulaR1C1 = "=IF(RC[-7]=R[-1]C[-7],,""PK"")" Selection.AutoFill Destination:=Range("H3:H10806") Range("H3:H10806").Select Columns("G:H").Select Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Selection.Replace What:="0", Replacement:="", LookAt:=xlWhole, _ SearchOrder:=xlByColumns, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Range("AH2").Select Application.CutCopyMode = False ActiveCell.FormulaR1C1 = "=IF(RC[1]=0,,""'01401"")" ActiveCell.FormulaR1C1 = "=IF(RC[1]=0,,""01401"")" Range("AH2").Select Selection.AutoFill Destination:=Range("AH2:AH10806") Range("AH2:AH10806").Select Columns("AH:AH").Select Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Selection.Replace What:="0", Replacement:="", LookAt:=xlWhole, _ SearchOrder:=xlByColumns, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Columns("AL:AL").Select Selection.Replace What:="0", Replacement:="", LookAt:=xlWhole, _ SearchOrder:=xlByColumns, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Application.CutCopyMode = False Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Selection.Find(What:="0", After:=ActiveCell, LookIn:=xlFormulas, LookAt _ :=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase _ :=False, SearchFormat:=False).Activate Selection.Replace What:="0", Replacement:="", LookAt:=xlWhole, _ SearchOrder:=xlByColumns, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Range("AI11").Select ActiveWindow.SmallScroll Down:=147 ActiveWindow.ScrollRow = 7950 ActiveWindow.SmallScroll Down:=-18 ActiveWindow.ScrollRow = 1 Range("AK6").Select ActiveWindow.ScrollColumn = 1 Application.CutCopyMode = False ActiveCell.FormulaR1C1 = "=IF(RC[-8]=R[-1]C[-8],"""",RC[-4])" Selection.AutoFill Destination:=Range("I2:I10806") Range("I2:I10806").Select End Sub
[/vba] При чем, если вот эту часть вынести в отдельный макрос, то ошибка не выскакивает [vba]Код
Application.CutCopyMode = False ActiveCell.FormulaR1C1 = "=IF(RC[-8]=R[-1]C[-8],"""",RC[-4])" Selection.AutoFill Destination:=Range("I2:I10806") Range("I2:I10806").Select
[/vba] GalinaS
Сообщение отредактировал GalinaS - Вторник, 28.02.2023, 15:23
Ответить
Сообщение Помогите, пожалуйста. Записывала макрос именно с помощью записи макроса. При выполнении макрос выдает ошибку Run-time error '1004': Метод Autofill из класса Range завершен неверно. Ругается на строчку Selection.AutoFill Destination:=Range("I2:I9806") [vba]Код
Cells.Select Selection.Replace What:="0", Replacement:="", LookAt:=xlWhole, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Selection.Replace What:="н/с", Replacement:="", LookAt:=xlWhole, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False ActiveWindow.ScrollColumn = 33 ActiveWindow.ScrollColumn = 26 ActiveWindow.SmallScroll Down:=57 ActiveWindow.ScrollRow = 2915 Selection.Replace What:="00.01.1900", Replacement:="", LookAt:=xlWhole, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False ActiveWindow.ScrollRow = 1 Range("AJ7").Select ActiveWindow.ScrollColumn = 1 ActiveWindow.ScrollColumn = 20 Range("Z2").Select ActiveWindow.ScrollColumn = 1 Range("D2").Select ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-2],'коды ТНВЭД'!R2C1:R3911C2,2,0)" Selection.AutoFill Destination:=Range("D2:D10806") Range("D2:D10806").Select Range("P2").Select ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-1],страны!R2C1:R256C2,2,0)" Selection.AutoFill Destination:=Range("P2:P10806") Range("P2:P10806").Select ActiveWindow.ScrollColumn = 12 ActiveWindow.ScrollColumn = 29 Range("AL2").Select ActiveCell.FormulaR1C1 = "=IF(RC[-1]=0,""С"")" Range("AL2").Select Selection.ClearContents Range("AL2").Select ActiveCell.FormulaR1C1 = "=IF(RC[-1]=0,""С"",0)" Columns("AK:AK").Select Selection.Replace What:="0", Replacement:="", LookAt:=xlWhole, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Range("AL2").Select ActiveCell.FormulaR1C1 = "=IF(RC[-1]=0,""С"",0)" Range("AL2").Select ActiveCell.FormulaR1C1 = "=IF(RC[-1]>0,0,""С"")" Range("AK2").Select ActiveCell.FormulaR1C1 = "1/0/1900" Range("AK2").Select Selection.Copy Range("AL2").Select Application.CutCopyMode = False ActiveCell.FormulaR1C1 = "=IF(RC[-1]>0,0,""С"")" Range("AK2").Select Selection.ClearContents Range("AL2").Select Selection.ClearContents Range("AL2").Select ActiveCell.FormulaR1C1 = "=IF(RC[-3]=0,""С"")" Selection.AutoFill Destination:=Range("AL2:AL10806") Range("AL2:AL10806").Select ActiveCell.FormulaR1C1 = "=IF(RC[-3]=0,""С"",""0"")" Range("AL2").Select Selection.AutoFill Destination:=Range("AL2:AL10806") Range("AL2:AL10806").Select Range("AL15").Select ActiveWindow.ScrollColumn = 1 Range("A2").Select ActiveCell.FormulaR1C1 = "=1" Range("V2").Select ActiveCell.FormulaR1C1 = "=1" Range("A3").Select ActiveCell.FormulaR1C1 = "=IF(RC[17]=0,R[-1]C,R[-1]C+1)" Selection.AutoFill Destination:=Range("A3:A10806") Range("A3:A10806").Select Range("V3").Select ActiveCell.FormulaR1C1 = "=IF(RC[-4]=0,R[-1]C+1,1)" Selection.AutoFill Destination:=Range("V3:V10806") Range("V3:V10806").Select ActiveWindow.ScrollRow = 1 Range("Z2:AA2").Select Selection.AutoFill Destination:=Range("Z2:AA10806") Range("Z2:AA703").Select Range("AF2").Select Selection.AutoFill Destination:=Range("AF2:AF10806") Range("AF2:AF703").Select ActiveWindow.SmallScroll Down:=276 ActiveWindow.ScrollRow = 647 ActiveWindow.SmallScroll Down:=45 ActiveWindow.ScrollRow = 7717 ActiveWindow.ScrollRow = 1 ActiveWindow.SmallScroll ToRight:=11 Range("AM2").Select ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-14],ТРОИС!R1C1:R2138C5,2,0)" Range("AN2").Select ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-15],ТРОИС!R1C1:R2126C5,3,0)" Range("AO2").Select ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-16],ТРОИС!R2C1:R2412C4,4,0)" Range("AM2:AO2").Select Selection.AutoFill Destination:=Range("AM2:AO10806") Range("AM2:AO703").Select ActiveWindow.ScrollRow = 2190 ActiveWindow.SmallScroll Down:=-60 ActiveWindow.ScrollRow = 647 ActiveWindow.SmallScroll Down:=-114 ActiveWindow.ScrollRow = 1 Range("AI2").Select ActiveWindow.ScrollColumn = 2 Columns("AM:AO").Select ActiveWorkbook.Save Columns("AM:AO").Select Selection.Copy Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _ xlNone, SkipBlanks:=False, Transpose:=False Selection.Replace What:="#?/?", Replacement:="", LookAt:=xlWhole, _ SearchOrder:=xlByColumns, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Range("AN10").Select Range("G3").Select ActiveCell.FormulaR1C1 = "=IF(RC[-6]=R[-1]C[-6],,1)" Selection.AutoFill Destination:=Range("G3:G10806") Range("G3:G10806").Select Range("H3").Select ActiveCell.FormulaR1C1 = "=IF(RC[-7]=R[-1]C[-7],,""PK"")" Selection.AutoFill Destination:=Range("H3:H10806") Range("H3:H10806").Select Columns("G:H").Select Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Selection.Replace What:="0", Replacement:="", LookAt:=xlWhole, _ SearchOrder:=xlByColumns, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Range("AH2").Select Application.CutCopyMode = False ActiveCell.FormulaR1C1 = "=IF(RC[1]=0,,""'01401"")" ActiveCell.FormulaR1C1 = "=IF(RC[1]=0,,""01401"")" Range("AH2").Select Selection.AutoFill Destination:=Range("AH2:AH10806") Range("AH2:AH10806").Select Columns("AH:AH").Select Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Selection.Replace What:="0", Replacement:="", LookAt:=xlWhole, _ SearchOrder:=xlByColumns, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Columns("AL:AL").Select Selection.Replace What:="0", Replacement:="", LookAt:=xlWhole, _ SearchOrder:=xlByColumns, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Application.CutCopyMode = False Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Selection.Find(What:="0", After:=ActiveCell, LookIn:=xlFormulas, LookAt _ :=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase _ :=False, SearchFormat:=False).Activate Selection.Replace What:="0", Replacement:="", LookAt:=xlWhole, _ SearchOrder:=xlByColumns, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Range("AI11").Select ActiveWindow.SmallScroll Down:=147 ActiveWindow.ScrollRow = 7950 ActiveWindow.SmallScroll Down:=-18 ActiveWindow.ScrollRow = 1 Range("AK6").Select ActiveWindow.ScrollColumn = 1 Application.CutCopyMode = False ActiveCell.FormulaR1C1 = "=IF(RC[-8]=R[-1]C[-8],"""",RC[-4])" Selection.AutoFill Destination:=Range("I2:I10806") Range("I2:I10806").Select End Sub
[/vba] При чем, если вот эту часть вынести в отдельный макрос, то ошибка не выскакивает [vba]Код
Application.CutCopyMode = False ActiveCell.FormulaR1C1 = "=IF(RC[-8]=R[-1]C[-8],"""",RC[-4])" Selection.AutoFill Destination:=Range("I2:I10806") Range("I2:I10806").Select
[/vba] Автор - GalinaS Дата добавления - 28.02.2023 в 11:31