Catalin Cernat
Catalin Cernat

Reputation: 137

VBA Excel Macro to update cell values based on multiple criteria

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:

  1. Column D must be blank.
  2. Must update only for the same values in column A.
  3. Column I ( Operation ) = LASER.
  4. 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.

enter image description here

I dont know if you understand this mess, but if you do, any help greatly appreciated.

Thanks alot!

Upvotes: 2

Views: 6919

Answers (1)

Shai Rado
Shai Rado

Reputation: 33682

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

Upvotes: 1

Related Questions