1.脚本语言有时不会报错,报错也不会按照正常的原因去反应
2.有固定的语法,该大写一定要大写
目前学习到的就只有导数的功能
嵌套循环
正确示范
function 程序名称()
{
rr=1;
for (let m=3;m<=100;m++)
{
if (Cells(5,m).Value2==null) {continue};
for (let i=7;i<=18;i++)
{
Sheets("bbb").Cells(rr,1).Value2="insert into tmp_kpi_scores
values('"+Cells(i,2).Value()+"','"+Cells(5,m).Value()+"',"+Cells(i,m).Value()+")"; rr=rr+1;
}
}
}
注释:
1.程序名称可以是中文和英文,不能自己写function,要运行程序的时候命名或者录制宏的时候
2.语法:Cells,Value2,Value(),Sheets 都要按照格式大写
3."" 中间是字符串,+ 把字符串和值链接在一起
输出: insert into tmp_kpi_scores values('230000000','111000000',1) 在bbb表中的第一列不同行
if 判断
function Macro1()
{
rr=1;
for (let i = 8 ; i <= 38 ; i++){
if (Cells(i,"HE").Value() == undefined || Cells(i,"HE").Value() == "-")
{Sheets("bbb").Cells(rr,1).Value2 = "insert into tmp_kpi_scores values('"+Cells(i,"B")+",'111110000',"+(0)+");";rr=rr+1}
else
{}
if (Cells(i,"GN").Value()==Cells(i,"GO").Value && Cells(i,"GO").Value()!=0)
{}
else if(Cells(i,"GN").Value()==Cells(i,"GO").Value && Cells(i,"GO").Value()==0)
{}
else
{}
}
}