debug de到脑壳疼,编程真的好难呀!
给自己定一个30天的学习计划,每天把熟练的代码以及弄不懂的问题记录在这里,每天进步一点点!
电脑上运行vba实在太费劲了!!!!!不玩了!
#1 累加器、计数器
1 | course | score |
2 | accouting | 90 |
3 | audit | 98 |
4 | IT audit | 95 |
Dim sum_score, num_c
'cells(x,2) add up to sum_score
for x = 2 to 4'cells(2,2) to cells(4,2)
sum_score = sum_score + cells(x,2)
num_c = num_c + 1
next x
#2 if判断语句
if score > 75 then
level = "A"
elseif score > 60 then
level = "B"
elseif score > 45 then
level = "C"
else
level = "D"
end if
#3 处理一个range里的数据
‘cells(x,y) ranges from cells(3,2) to cells(5,4)
for x = 3 to 5
for y = 2 to 4
cells(x,y) = cells(x,y) * 100
next y
next x
#4 对于当前工作簿的每张工作表的A1单元格写入666
'x is the variance for the location of each worksheet
For x = 1 To Worksheets.count
Set w = Worksheets(x)
w.Cells(1, 1) = 666
Next x
#5 自动添加2张新工作表,且在新工作表的A1写入666
for x = 1 to 2
set wa = worksheets.add
wa.cells(1,1) = 666
next x
#6 workbook是lily的月度成绩表,每张worksheet是lily每次月考的成绩明细,将每张worksheet的成绩汇总