In my worksheet 'Events' the following vba code deletes a row if the row value in column…
- User
In my worksheet 'Events' the following vba code deletes a row if the row value in column E is equals to 'Close' as shown below; For i = 2 To lastRow If LCase(eventsSheet.Range("E" & i).Value) = "close" Then response = MsgBox("Do you want to delete this row?" & vbNewLine & _ eventsSheet.Range("B" & i).Value & vbNewLine & _ eventsSheet.Range("C" & i).Value & vbNewLine & _ eventsSheet.Range("D" & i).Value & vbNewLine & _ eventsSheet.Range("E" & i).Value, vbYesNo) If response = vbYes Then eventsSheet.Rows(i).Delete lastRow = lastRow - 1 ' Update LastRow after deleting the row i = i - 1 ' Loop counter must decrease by one to check the new row that moved up eventsSheet.Calculate ' Refresh conditional formatting End If End If If eventsSheet.Range("B" & i).Value = "" Then Exit For ' Exit loop if first empty row is reached Next i
I would like to amend the formula to do the following. For each row in worksheet 'Events' that is deleted, copy the row values only in columns A, B, C, & D, to the next available row in worksheet'Events History'
- Assistant
You can amend the code by adding the logic to copy the row values to the "Events History" worksheet. Here's the updated code:
vba