VBA Excel宏根据多个条件更新单元格值 [英] VBA Excel Macro to update cell values based on multiple criteria
问题描述
- 列D必须为空。
- 必须仅在列A中更新相同的值。
- 列I(操作)= LASER。
然后用列E更新Operation = SUDURA的列E值操作价值LASER + 10天。
我不知道你是否理解这个混乱,但是如果你这样做,任何帮助都非常感激。
谢谢alot!
尝试下面的短代码,它在我的测试中工作有限的数据记录。让我知道它是否适用于您的数据。
Sub UpdateVEPlanning()
Dim sht As Worksheet
Dim LastRow,lRow As Long
'将Sheet1修改为您有
的任何工作表名称设置sht = ThisWorkbook.Worksheets(Sheet1)
'在数据表中找到最后一行
LastRow = sht.Cells(sht.Rows.Count,A)。End(xlUp).row
对于lRow = 2 To LastRow
如果sht.Cells(lRow,1)= sht.Cells(lRow - 1,1)然后
如果不是(sht.Cells(lRow,9 ).Find(SUDURA)Is Nothing)And(IsEmpty(sht.Cells(lRow,4).Value2)或sht.Cells(lRow,4).Value2 <= 0)Then
如果sht。单元格(lRow,6)= sht.Cells(lRow - 1,6)然后
sht.Cells(lRow,5)= sht.Cells(lRow - 1,5)+ 10
End If
如果
结束如果
下一个
End Sub
It is impossible for me to solve this, im at my boiling points upper limit, so i could really use your directions or help. I've attached an image in the header. I need a vba macro to update / change the values in column E ( Ve Planning ) with the following contitions:
- Column D must be blank.
- Must update only for the same values in column A.
- Column I ( Operation ) = LASER.
- If column F ( W NO ) values are equal.
Then update the column E value for Operation = SUDURA with column E value for operation LASER + 10 days.
I dont know if you understand this mess, but if you do, any help greatly appreciated.
Thanks alot!
Try the short code below, it worked in my test with limited Data records. Let me know if it works on your data as well.
Sub UpdateVEPlanning()
Dim sht As Worksheet
Dim LastRow, lRow As Long
' modify "Sheet1" to whatever worksheet name you have
Set sht = ThisWorkbook.Worksheets("Sheet1")
' find last row in sheet with data
LastRow = sht.Cells(sht.Rows.Count, "A").End(xlUp).row
For lRow = 2 To LastRow
If sht.Cells(lRow, 1) = sht.Cells(lRow - 1, 1) Then
If Not (sht.Cells(lRow, 9).Find("SUDURA") Is Nothing) And (IsEmpty(sht.Cells(lRow, 4).Value2) Or sht.Cells(lRow, 4).Value2 <= 0) Then
If sht.Cells(lRow, 6) = sht.Cells(lRow - 1, 6) Then
sht.Cells(lRow, 5) = sht.Cells(lRow - 1, 5) + 10
End If
End If
End If
Next
End Sub
这篇关于VBA Excel宏根据多个条件更新单元格值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!