Sub RequestsCalculate() Worksheets("CRequests").Visible = True…
- User
Sub RequestsCalculate() Worksheets("CRequests").Visible = True Worksheets("CRequests").Calculate Application.Wait (Now + TimeValue("0:00:01")) Worksheets("ClnRequests").Calculate Worksheets("CRequests").Visible = False ActiveSheet.Cells.WrapText = True End Sub
- Assistant
This VBA code subroutine calculates the formulas on two worksheets ("CRequests" and "ClnRequests"). It also sets the "CRequests" worksheet as visible, waits for 1 second, calculates the "ClnRequests" worksheet, hides the "CRequests" worksheet, and wraps the text in the active sheet cells.
- User
I would like to add the following condition to the end of the VBA code below. If the active sheet cell value in column D = "" then the value in same row of column H must = ""
Sub RequestsCalculate() Worksheets("CRequests").Visible = True Worksheets("CRequests").Calculate Application.Wait (Now + TimeValue("0:00:01")) Worksheets("ClnRequests").Calculate Worksheets("CRequests").Visible = False ActiveSheet.Cells.WrapText = True End Sub
- Assistant
Here's the updated code with the condition you specified:
VBASub RequestsCalculate() Worksheets("CRequests").Visible = True Worksheets("CRequests").Calculate Application.Wait (Now + TimeValue("0:00:01")) Worksheets("ClnRequests").Calculate Worksheets("CRequests").Visible = False ActiveSheet.Cells.WrapText = True Dim lastRow As Long lastRow = ActiveSheet.Cells(Rows.Count, "D").End(xlUp).Row For i = 2 To lastRow If ActiveSheet.Cells(i, "D").Value = "" Then ActiveSheet.Cells(i, "H").Value = "" End If Next i End SubThis code will loop through each row starting from row 2 until the last row with data in column D. If the value in column D of the current row is blank, it will set the value in column H of the same row to blank as well.