|
楼主 |
发表于 2018-8-27 08:46
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Application.ScreenUpdating = False
'''''普铝 BGY45平开窗 三扇-左下1亮+右下1亮=45
Dim i&, findcell As Range
Dim bgy4504, bgy4502, bgy4501, bgy4529, bgy4531, bgy4508a, bgy4506, bgy4507, bgy4505, bgy4522, bgy4525, bgy4527, bgy45a06a, bgy4511, bgy4509, bgy4530, st9, st19, aa, bb As Integer
For i = 5 To [b65536].End(xlUp).Row
If Cells(i, 5) = "普铝" And Cells(i, 6) = "BGY45平开窗" And Cells(i, 7) = "三扇-左下1亮+右下1亮=45" Then
Cells(i, 29) = 3 '扇数
Cells(i, 33) = 5 '玻璃块数
Set findcell = Rows("2").Find("BGY4504", lookat:=xlWhole) 'BGY4504窗扇上框
bgy4504 = findcell.Column
Cells(i, bgy4504).Value = Cells(i, 10) - kf1 * 2
Set findcell = Rows("2").Find("BGY4502", lookat:=xlWhole) 'BGY4502窗下框
bgy4502 = findcell.Column
Cells(i, bgy4502).Value = Cells(i, 10) - kf1 * 2
Set findcell = Rows("2").Find("BGY4501", lookat:=xlWhole) 'BGY4501窗边框
bgy4501 = findcell.Column
Cells(i, bgy4501).Value = Cells(i, 11) * 2
Set findcell = Rows("2").Find("BGY4529", lookat:=xlWhole) 'BGY4529扇组角码
bgy4529 = findcell.Column
Cells(i, bgy4529).Value = 0.0417 * 4 * 3
Set findcell = Rows("2").Find("BGY4531", lookat:=xlWhole) 'BGY4531滑撑垫料
bgy4531 = findcell.Column
Cells(i, bgy4531).Value = 0.25 * 2 * 3
Select Case Cells(i, 36) '中工为变量
Case Is = "BGY4508A+BGY4506+BGY4507"
Cells(i, 27) = Cells(i, 12) - kf3 - kf4 '窗扇宽度,考虑表格格式问题,采用扣减较少尺寸做扇宽
Cells(i, 28) = Cells(i, 18) - kf5 - kf3 '窗扇高度
Cells(i, 29) = 2 '窗扇数量
Cells(i, 30) = Cells(i, 14) - kf6 - kf4 '窗扇宽度
Cells(i, 31) = Cells(i, 18) - kf5 - kf3 '窗扇高度
Cells(i, 32) = 1 '窗扇数量
Set findcell = Rows("2").Find("BGY4508A", lookat:=xlWhole) '中工BGY4508A
bgy4508a = findcell.Column
Cells(i, bgy4508a).Value = Cells(i, 10) - kf1 * 2 - kf2
Set findcell = Rows("2").Find("BGY4506", lookat:=xlWhole) '中工BGY4506
bgy4506 = findcell.Column
Cells(i, bgy4506).Value = Cells(i, 18) - kf7 - kf8
Set findcell = Rows("2").Find("BGY4507", lookat:=xlWhole) '中工BGY4507
bgy4507 = findcell.Column
Cells(i, bgy4507).Value = Cells(i, 11) - kf7 - kf1
Set findcell = Rows("2").Find("BGY4505", lookat:=xlWhole) '窗扇BGY4505
bgy4505 = findcell.Column
Cells(i, bgy4505).Value = Cells(i, 27) * 4 + Cells(i, 28) * 4 + Cells(i, 30) * 2 + Cells(i, 31) * 2
Set findcell = Rows("2").Find("BGY4530", LookIn:=xlValues, lookat:=xlWhole) '中工连接件BGY4530
bgy4530 = findcell.Column
Cells(i, bgy4530).Value = 0.0087 * 4
Select Case Cells(i, 35) '玻璃为变量
Case Is = "中空"
Set findcell = Rows("2").Find("BGY4525", lookat:=xlWhole) '斜压线BGY4525
bgy4525 = findcell.Column
Cells(i, bgy4525).Value = (Cells(i, 27) - kf9 * 2 - kf10) * 4 + (Cells(i, 28) - kf9 * 2 - kf11) * 4 + (Cells(i, 30) - kf9 * 2 - kf10) * 2 + (Cells(i, 31) - kf9 * 2 - kf11) * 2 _
+ (Cells(i, 12) + Cells(i, 13) - kf12 - kf13 - kf10) * 2 + (Cells(i, 19) - kf14 - kf12 - kf11) * 2 _
+ (Cells(i, 14) - kf13 - kf12 - kf10) * 2 + (Cells(i, 19) - kf14 - kf12 - kf11) * 2
End Select
End Select
End If
Next
Application.ScreenUpdating = True
End Sub
以上是关于计算过程的主过程代码,请教各位老师如何将结果转化为“公式”写入相应的单元格内? |
|