在excel里如何利用VBA实现图中所要求的处理?
1个回答
展开全部
Sub test4()
Dim i&, j&
Range([b2], [p4]).ClearFormats
For i = 2 To 4
For j = 2 To 16
If Cells(i, j) = "" Then
Cells(i, j).Interior.Color = vbGreen
GoTo Step1
End If
Next j
Step1:
If i = 2 Then
Cells(i, 17) = "=b" & i & "+sum(d" & i & ":f" & i & ")+sum(h" & i & ":m" & i & ")"
Else
Cells(i, 17) = "=sum(b" & i & "+d" & i & ")+sum(f" & i & ":i" & i & ")+sum(k" & i & ":o" & i & ")"
End If
Next i
End Sub
Dim i&, j&
Range([b2], [p4]).ClearFormats
For i = 2 To 4
For j = 2 To 16
If Cells(i, j) = "" Then
Cells(i, j).Interior.Color = vbGreen
GoTo Step1
End If
Next j
Step1:
If i = 2 Then
Cells(i, 17) = "=b" & i & "+sum(d" & i & ":f" & i & ")+sum(h" & i & ":m" & i & ")"
Else
Cells(i, 17) = "=sum(b" & i & "+d" & i & ")+sum(f" & i & ":i" & i & ")+sum(k" & i & ":o" & i & ")"
End If
Next i
End Sub
更多追问追答
追问
我想要的是染绿后,再对绿色部分对应的时刻所形成的空白时间段输出到q列,比如序号1所在行的时间段有:2013.8.1-2013.8.31、2013.10.1-2013.12.31、2014.2.1-2014.7.31,不是对空白时间段求和!!
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询