Здравствуйте. Пытаюсь понять как сделать так, чтобы FormulaR1C1 вставляла формулы в каждую 24 ячейку столбца. Но как только код добирается до строки [vba]
Код
Cells.Item(i, 10).FormulaR1C1 = "= RC[-2]+RC[-1]"
[/vba] Заполняются все ячейки столбца. Можно ли как-то это изменить? Спасибо.
Здравствуйте. Пытаюсь понять как сделать так, чтобы FormulaR1C1 вставляла формулы в каждую 24 ячейку столбца. Но как только код добирается до строки [vba]
Код
Cells.Item(i, 10).FormulaR1C1 = "= RC[-2]+RC[-1]"
[/vba] Заполняются все ячейки столбца. Можно ли как-то это изменить? Спасибо.geometridae
Sub Date_And_Time_GAZ_2() Dim start_time As Date, i As Integer, Arr(), bool As Boolean, calc&
start_time = InputBox("Введите дату, с которой начнётся таблица. Например 01.01.2019") Arr = [transpose(transpose(mod(row(r1:r24),24)))/24] With Application bool = .AutoCorrect.AutoFillFormulasInLists .AutoCorrect.AutoFillFormulasInLists = False: calc = .Calculation .ScreenUpdating = 0: .EnableEvents = 0: .Calculation = xlCalculationManual With .ActiveSheet.ListObjects.Add(xlSrcRange, Range(Cells(1, 1), Cells(10010, 10)), , xlNo) .Name = "ГАЗ" For i = 2 To (.ListRows.Count \ 24) * 24 Step 24 With .ListColumns(1).Range.Cells(i) .Value = start_time + i \ 24 With .Offset(, 1).Resize(24) .Value = Arr .NumberFormat = "hh:mm" End With .Offset(23, 2).Resize(, 5).Borders(xlEdgeBottom).Weight = xlThick With .Offset(23, 7).Resize(, 3) .Interior.ColorIndex = 27 .Borders.Weight = xlThick .Cells(1, 3).FormulaR1C1 = "= RC[-2]+RC[-1]" End With End With Next End With Application.AutoCorrect.AutoFillFormulasInLists = bool .ScreenUpdating = 1: .EnableEvents = 1: .Calculation = calc End With End Sub
[/vba]
в начале кода [vba]
Код
dim bool as Boolean bool = Application.AutoCorrect.AutoFillFormulasInLists Application.AutoCorrect.AutoFillFormulasInLists = False
Sub Date_And_Time_GAZ_2() Dim start_time As Date, i As Integer, Arr(), bool As Boolean, calc&
start_time = InputBox("Введите дату, с которой начнётся таблица. Например 01.01.2019") Arr = [transpose(transpose(mod(row(r1:r24),24)))/24] With Application bool = .AutoCorrect.AutoFillFormulasInLists .AutoCorrect.AutoFillFormulasInLists = False: calc = .Calculation .ScreenUpdating = 0: .EnableEvents = 0: .Calculation = xlCalculationManual With .ActiveSheet.ListObjects.Add(xlSrcRange, Range(Cells(1, 1), Cells(10010, 10)), , xlNo) .Name = "ГАЗ" For i = 2 To (.ListRows.Count \ 24) * 24 Step 24 With .ListColumns(1).Range.Cells(i) .Value = start_time + i \ 24 With .Offset(, 1).Resize(24) .Value = Arr .NumberFormat = "hh:mm" End With .Offset(23, 2).Resize(, 5).Borders(xlEdgeBottom).Weight = xlThick With .Offset(23, 7).Resize(, 3) .Interior.ColorIndex = 27 .Borders.Weight = xlThick .Cells(1, 3).FormulaR1C1 = "= RC[-2]+RC[-1]" End With End With Next End With Application.AutoCorrect.AutoFillFormulasInLists = bool .ScreenUpdating = 1: .EnableEvents = 1: .Calculation = calc End With End Sub