I have Data In Col D. I have VBA Code that inserts formulas and after the Code has Run and there blank cells in Col D where there is data in Col C in same row , then message box to state "Missing Descriptions" eg missing descriptions in D2, D5 etc . Col D2 onwards has a formula
When running the code, the only part not displaying isn the message box
It would be appreciated if someone could kindly amend my code
See link to my sample data below
Code:
=IFERROR(INDEX(Codes!$AC$2:$AC$15,MATCH(TRUE,ISNUMBER(SEARCH(Codes!$AB$2:$AB$15,E2)),0)),"")
When running the code, the only part not displaying isn the message box
It would be appreciated if someone could kindly amend my code
See link to my sample data below
Code:
Sub Formula()
Formula_Description
CopyAssetType_Surname
With Sheets("Fassets")
Dim LR As Long
LR = .Cells(.Rows.Count, "A").End(xlUp).Row
If .Range("A2") = "" Then
Exit Sub
End If
.Range("B2:B" & LR).FormulaR1C1 = _
"=VLOOKUP(RC[-1],'C:\Fixed Asset Upload Templates\[fixed Asset Upload Template.xlsm]Table'!R2C1:R22C3,2,FALSE)"
.Range("J2:J" & LR).FormulaR1C1 = _
"=VLOOKUP(RC[-9],'C:\Fixed Asset Upload Templates\[Fixed Asset Upload Template.xlsm]Table'!R2C1:R23C3,3,FALSE)"
.Range("K2:K" & LR).FormulaR1C1 = "=RC[1]"
.Range("R2:R" & LR).FormulaR1C1 = "=Codes!RC[4]&""=100"""
' Check for blank cells in Col D where there is data in Col C in the same row
Dim i As Long
Dim missingDescriptions As Boolean
missingDescriptions = False
For i = 2 To LR
' Use Evaluate to get the result of the formula in column D
Dim cellDResult As Variant
cellDResult = Application.Evaluate(.Range("D" & i).Formula)
' Check if the result is an empty string and Col C is not blank
If cellDResult = "" And .Range("C" & i).Value <> "" Then
Debug.Print "Missing Descriptions in cell D" & i
missingDescriptions = True
End If
Next i
If missingDescriptions Then
MsgBox "Some Descriptions are missing. Please check the highlighted cells."
End If
End With
End Sub
Sub Formula_Description()
Dim LR As Long, LR1 As Long
Dim lastRow As Long
With Sheets("Codes")
lastRow = .Cells(.Rows.Count, "AB").End(xlUp).Row
End With
With Sheets("Fassets")
LR = .Cells(.Rows.Count, "E").End(xlUp).Row
.Range("D2:D" & LR).Formula2R1C1 = _
"=IFERROR(INDEX(Codes!R2C29:R" & lastRow & "C29,MATCH(TRUE,ISNUMBER(SEARCH(Codes!R2C28:R" & lastRow & "C28,RC[1])),0)),"""")"
LR1 = .Cells(.Rows.Count, "E").End(xlUp).Row
.Range("I2:I" & LR1).FormulaR1C1 = "=EOMONTH(NOW(),-2)+1"
End With
Clear_Errors
End Sub
Sub CopyAssetType_Surname()
Dim LR As Long
With Sheets("Fassets")
LR = .Cells(.Rows.Count, "E").End(xlUp).Row
.Range("A2:A" & LR).Value = "'Computer Equipment"
.Range("O2:O" & LR).Value = "Administration"
End With
End Sub