I have an Excel workbook with 2 master sheets and one data entry sheet.
Project Master:
|Project No |Asset No |
|------------|------------|
|P01 |A01 |
Asset Master:
|Asset No |Description |
|-----------|--------------|
|A01 |Testing |
For my data entry sheet, I want to use Project No as my reference and use Index/Match formula in VBA to search for the other 2 fields. In this case:
|Project No |Asset No |Description |
|------------|-----------|-------------|
|P01 |A01 |Testing |
I also want the data entry sheet to only change the selected row instead of refreshing the entire sheet whenever I change a single cell. So in VBA data entry sheet I used the code:
Private Sub worksheet_change(ByVal target As Range)
If Not Intersect(target, Range("a9:a9999")) Is Nothing Then
'---------------------------------------------------------------
With target.Offset(0, 1)
.FormulaR1C1 = "=IF(ISNA(INDEX(ProjectEntry,MATCH(rc1,ProjectEntry[Project No],FALSE),2)),"""",INDEX(ProjectEntry,MATCH(rc1,ProjectEntry[Project No],FALSE),2))"
.Value = .Value
End With
With target.Offset(0, 2)
.FormulaR1C1 = "=IF(ISNA(INDEX(AssetMaster,MATCH(rc1,AssetMaster[Asset No],FALSE),2)),"""",INDEX(AssetMaster,MATCH(rc1,AssetMaster[Asset No],FALSE),2))"
.Value = .Value
End With
End If
End Sub
When I used this code, only the asset no appears while description remains empty. The code should supposedly perform change in the row whenever a cell in the range I selected (a9:a9999) has its value changed.
Is this due to code limitation having to refer to 2 master sheets that it only refers to only Project Master while Asset Master is ignored? Is there a way to solve this issue?