我从不同的文件中收集了大量数据.在这个主要工作簿中,我为每个单元格提供了不同类型的公式.在范围A到F中是收集来自其他文件的数据的位置.在H到AC的范围内,每次输入新数据时,我都会通过手动拖动来自动填充公式.下面的代码是我使用的,它只有6个不同的公式,我想自动填充.
Application.ScreenUpdating = False
lastRow = Range("B" & Rows.Count).End(xlUp).Row
Range("D2").Formula = "=$L$1/$L$2"
Range("D2").AutoFill Destination:=Range("D2:D" & lastRow)
Range("E2").Formula = "=$B2/2116"
Range("E2").AutoFill Destination:=Range("E2:E" & lastRow)
Range("F2").Formula = "=$D$2+(3*SQRT(($D$2*(1-$D$2))/2116))"
Range("F2").AutoFill Destination:=Range("F2:F" & lastRow)
Range("G2").Formula = "=$D$2-(3*SQRT(($D$2*(1-$D$2))/2116))"
Range("G2").AutoFill Destination:=Range("G2:G" & lastRow)
Range("H2").Formula = "=IF($E2>=$F2,$E2,NA())"
Range("H2").AutoFill Destination:=Range("H2:H" & lastRow)
Range("I2").Formula = "=IF($E2<=$G2,$E2,NA())"
Range("I2").AutoFill Destination:=Range("I2:I" & lastRow)
ActiveSheet.AutoFilterMode = False
Application.ScreenUpdating = True
Run Code Online (Sandbox Code Playgroud)
但是,在主工作簿中,有15个不同的公式,我希望每次新数据进入时自动填充.我有多个主要工作簿,并且公式不是常数.为每个公式插入上面的代码是一件痛苦的事.有没有办法可以让程序自动拖动它?在主要工作簿中,我已经写出了公式.我尝试了许多不同的代码使其自动填充,但到目前为止,上面的那个是唯一一个没有给我错误的工作.我试过使用类似这个或类似版本的东西,但没有一个工作:
With wbList.Sheets("Attribute - 10 mil stop")
lastRow = Worksheets(ActiveSheet.Name).Range("B2").Rows.Count
'Worksheets(ActiveSheet.Name).Range(Selection, Selection.End(xlDown)).Select
Worksheets(ActiveSheet.Name).Range("D2:I2").Select
Selection.AutoFill Destination:=Range("D2:I" & Range("B2" & Rows.Count).End(xlDown).Row)
End With
Run Code Online (Sandbox Code Playgroud)
我对代码搞砸了很多.我甚至都不知道它是否会像那样.谢谢你的帮忙!
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <sstream>
using namespace std;
int main(){
float size;
float sumNum = 0;
float maxNum, minNum;
float mean;
float totalDev = 0;
float devSqr = 0;
float stdDev;
//Create a user input size
std::cout << "How many number would you like to enter? ";
std::cin >> size;
float *temp = new float[size];
//Getting input from the user
for (int x = 1; x <= size; x++){
cout << "Enter temperature " << …Run Code Online (Sandbox Code Playgroud)