Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel 如何在Access中为下面显示的代码创建VBA循环? Dim Q为整数,F为整数,V为整数,小时为整数,小时1为整数,小时2为整数,小时3为整数,小时4为整数,小时5为整数,小时6为整数, Q=表格!frmweekhrs!txtT F=0.9*Q V=1.1*Q 小时=工作表范围(“b4”)值 小时1=板材范围(“b5”)值 小时数2=板材范围(“b6”)值 小时3=板材范围(“b7”)值 小时4=板材范围(“b8”)值 小时5=板材范围(“b9”)值 小时6=板材范围(“b10”)值 如果小时1>F且小时1F且小时2F且小时3F且小时4F且小时5F且小时6_Excel_Vba - Fatal编程技术网

Excel 如何在Access中为下面显示的代码创建VBA循环? Dim Q为整数,F为整数,V为整数,小时为整数,小时1为整数,小时2为整数,小时3为整数,小时4为整数,小时5为整数,小时6为整数, Q=表格!frmweekhrs!txtT F=0.9*Q V=1.1*Q 小时=工作表范围(“b4”)值 小时1=板材范围(“b5”)值 小时数2=板材范围(“b6”)值 小时3=板材范围(“b7”)值 小时4=板材范围(“b8”)值 小时5=板材范围(“b9”)值 小时6=板材范围(“b10”)值 如果小时1>F且小时1F且小时2F且小时3F且小时4F且小时5F且小时6

Excel 如何在Access中为下面显示的代码创建VBA循环? Dim Q为整数,F为整数,V为整数,小时为整数,小时1为整数,小时2为整数,小时3为整数,小时4为整数,小时5为整数,小时6为整数, Q=表格!frmweekhrs!txtT F=0.9*Q V=1.1*Q 小时=工作表范围(“b4”)值 小时1=板材范围(“b5”)值 小时数2=板材范围(“b6”)值 小时3=板材范围(“b7”)值 小时4=板材范围(“b8”)值 小时5=板材范围(“b9”)值 小时6=板材范围(“b10”)值 如果小时1>F且小时1F且小时2F且小时3F且小时4F且小时5F且小时6,excel,vba,Excel,Vba,此代码扫描人时数,并根据数字的好坏将金额标记为绿色或红色。我还有大约40个,不知道如何为此创建循环,如果您需要任何信息,请告诉我。Dim Q为整数,F为整数,V为整数,hours为整数 Dim Q As Integer, F As Integer, V As Integer, hours As Integer, hours1 As Integer, hours2 As Integer, hours3 As Integer, hours4 As Integer, hours5 As Integer

此代码扫描人时数,并根据数字的好坏将金额标记为绿色或红色。我还有大约40个,不知道如何为此创建循环,如果您需要任何信息,请告诉我。

Dim Q为整数,F为整数,V为整数,hours为整数
Dim Q As Integer, F As Integer, V As Integer, hours As Integer, hours1 As Integer, hours2 As Integer, hours3 As Integer, hours4 As Integer, hours5 As Integer, hours6 As Integer, 


Q = Forms!frmweekhrs!txtWeeks * t
F = 0.9 * Q
V = 1.1 * Q
hours = Sheet.Range("b4").Value
hours1 = Sheet.Range("b5").Value
hours2 = Sheet.Range("b6").Value
hours3 = Sheet.Range("b7").Value
hours4 = Sheet.Range("b8").Value
hours5 = Sheet.Range("b9").Value
hours6 = Sheet.Range("b10").Value


If hours1 > F And hours1 < V Then
Sheet.Range("b5").Interior.ColorIndex = 4
Else
Sheet.Range("b5").Interior.ColorIndex = 3
End If

If hours2 > F And hours2 < V Then
Sheet.Range("b6").Interior.ColorIndex = 4
Else
Sheet.Range("b6").Interior.ColorIndex = 3
End If

If hours3 > F And hours3 < V Then
Sheet.Range("b7").Interior.ColorIndex = 4
Else
Sheet.Range("b7").Interior.ColorIndex = 3
End If

If hours4 > F And hours4 < V Then
Sheet.Range("b8").Interior.ColorIndex = 4
Else
Sheet.Range("b8").Interior.ColorIndex = 3
End If`

If hours5 > F And hours5 < V Then
Sheet.Range("b9").Interior.ColorIndex = 4
Else
Sheet.Range("b9").Interior.ColorIndex = 3
End If

If hours6 > F And hours6 < V Then
Sheet.Range("b10").Interior.ColorIndex = 4
Else
Sheet.Range("b10").Interior.ColorIndex = 3
End If
Q=表格!frmweekhrs!txtT F=0.9*Q V=1.1*Q '启动焦点行上的循环 对于i=4的ActiveSheet.Cells(Rows.Count,2).End(xlUp).Row 小时=ActiveSheet.Range(“b”&i).值 如果小时数>F,小时数
谢谢,这非常有效!哇,去掉了这么多多余的不必要的代码。你使用了固定值i=4到10。如果要突出显示的记录数量的值在不断增加或减少,我如何将I=4设置为(未确定的数量)?我编辑了答案以查找最后一行。要找到第一行,我必须更多地了解数据的结构。是否有标题?以前的DBA包含许多不同的变量,这些变量删除了额外的excel电子表格,命名并标识了当前的表格,因此使用更新的代码会产生错误“下标超出范围”。是否应将“Sheet1”替换为活动图纸的对象名称?如果你需要更多的细节,请告诉我。此外,还有一个标题,第一行固定为从5开始,因此以“i=5”开头效果很好。是的,您可以使用
ActiveSheet.Range([…])
表示法或
Sheets(“Sheet1”)
,根据上下文使用您所说的活动表对象名称。
Dim Q As Integer, F As Integer, V As Integer, hours As Integer

Q = Forms!frmweekhrs!txtWeeks * t
F = 0.9 * Q
V = 1.1 * Q
'initiate loop over focal rows
For i = 4 To ActiveSheet.Cells(Rows.Count, 2).End(xlUp).Row
    hours = ActiveSheet.Range("b" & i).Value

    If hours > F And hours < V Then
        ActiveSheet.Range("b" & i).Interior.ColorIndex = 4
    Else
        ActiveSheet.Range("b" & i).Interior.ColorIndex = 3
    End If
Next i