vba 代码解释?
Sub按钮3_单击()temp=0.2Fori=9To21Columns(i).SelectSelection.ColumnWidth=(Cells(3,i+1)-Cel...
Sub 按钮3_单击()
temp = 0.2
For i = 9 To 21
Columns(i).Select
Selection.ColumnWidth = (Cells(3, i + 1) - Cells(3, i)) * temp
Next i
For i = 4 To 35
If Range("f" & i) <> "" Then
kaishi = Range("e" & i) - Range("i3")
changdu = Range("f" & i) - Range("e" & i)
jieshu = changdu + kaishi
temp = Range("i" & 3).Width / 31
ActiveSheet.Shapes.AddLine(Range("i" & i).Left + kaishi * temp, Range("i" & i).Top + 0.5 * Range("i" & i).Height, Range("i" & i).Left + jieshu * temp, Range("i" & i).Top + 0.5 * Range("i" & i).Height).Select
Selection.ShapeRange.Line.Weight = 3#
End If
Next i
End Sub 展开
temp = 0.2
For i = 9 To 21
Columns(i).Select
Selection.ColumnWidth = (Cells(3, i + 1) - Cells(3, i)) * temp
Next i
For i = 4 To 35
If Range("f" & i) <> "" Then
kaishi = Range("e" & i) - Range("i3")
changdu = Range("f" & i) - Range("e" & i)
jieshu = changdu + kaishi
temp = Range("i" & 3).Width / 31
ActiveSheet.Shapes.AddLine(Range("i" & i).Left + kaishi * temp, Range("i" & i).Top + 0.5 * Range("i" & i).Height, Range("i" & i).Left + jieshu * temp, Range("i" & i).Top + 0.5 * Range("i" & i).Height).Select
Selection.ShapeRange.Line.Weight = 3#
End If
Next i
End Sub 展开
1个回答
展开全部
Sub 按钮3_单击()
temp = 0.2 '临时使用的中间变量
For i = 9 To 21
Columns(i).Select
Selection.ColumnWidth = (Cells(3, i + 1) - Cells(3, i)) * temp
'依次设置第9~第21列的列宽,i列的列宽数值是第3行第i+1列单元格中的值与第3行i列的值差值乘以中间变量
Next i
For i = 4 To 35
If Range("f" & i) <> "" Then '判断F列,第4~35行内容是否为空
kaishi = Range("e" & i) - Range("i3") 'E列i行的值与I3单元格的值的差值存放到kaishi变量
changdu = Range("f" & i) - Range("e" & i) 'F列i行与E列i行差值存放到changdu变量
jieshu = changdu + kaishi 'changdu和kaishi变量的和存放在jieshu变量
temp = Range("i" & 3).Width / 31 '重新计算中间变量temp
ActiveSheet.Shapes.AddLine(Range("i" & i).Left + kaishi * temp, Range("i" & i).Top + 0.5 * Range("i" & i).Height, Range("i" & i).Left + jieshu * temp, Range("i" & i).Top + 0.5 * Range("i" & i).Height).Select '添加线段
Selection.ShapeRange.Line.Weight = 3# '设置线宽
End If
Next i
End Sub
temp = 0.2 '临时使用的中间变量
For i = 9 To 21
Columns(i).Select
Selection.ColumnWidth = (Cells(3, i + 1) - Cells(3, i)) * temp
'依次设置第9~第21列的列宽,i列的列宽数值是第3行第i+1列单元格中的值与第3行i列的值差值乘以中间变量
Next i
For i = 4 To 35
If Range("f" & i) <> "" Then '判断F列,第4~35行内容是否为空
kaishi = Range("e" & i) - Range("i3") 'E列i行的值与I3单元格的值的差值存放到kaishi变量
changdu = Range("f" & i) - Range("e" & i) 'F列i行与E列i行差值存放到changdu变量
jieshu = changdu + kaishi 'changdu和kaishi变量的和存放在jieshu变量
temp = Range("i" & 3).Width / 31 '重新计算中间变量temp
ActiveSheet.Shapes.AddLine(Range("i" & i).Left + kaishi * temp, Range("i" & i).Top + 0.5 * Range("i" & i).Height, Range("i" & i).Left + jieshu * temp, Range("i" & i).Top + 0.5 * Range("i" & i).Height).Select '添加线段
Selection.ShapeRange.Line.Weight = 3# '设置线宽
End If
Next i
End Sub
追问
temp 不是关键字吧 可以换成其他的?
3# #是设置格式?
Sub 按钮8_单击()
shul = ActiveSheet.Shapes.Count
For i = shul To 1 Step -1
temp = ActiveSheet.Shapes(i).Name
If InStr(temp, "Line") > 0 Then
ActiveSheet.Shapes(i).Delete
Else
'MsgBox ActiveSheet.Shapes(i).Name
End If
Next i
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询