I am trying to smarten up the attached excel spreadsheet using vba (sorry image attached). The sheet has a fixed value in cell D161, set at 45, Index match uses this value to return a summary of the values in the critical columns. I have attached a couple of modules with the sheet module one searches and finds and active cell based upon the input value of D161. I have seen a couple of examples and have become more confused than usual My work flow is:
select and active cell value, based upon D161ās value
Use this cell value as the active cell
Select the critical columns (highlighted in lt blue) based upon this active cell (using offset) There are 5 columns distributed through the array of values
Select the columns and present them in a summary table as shown in array D161:K167
I have found a topic that is similar however Iām moderately puzzled as its beyond my vba experience
Excel / VBA - Index Match function using Dynamic Ranges
My Code
Sub FindThisValue()
Dim varLookFor As Variant
Dim GBAnchorageRng As Range
Dim GBLapRng As Range
Dim OCAnchorageRng As Range
Dim OCLapRng As Range
varLookFor = Range("D161").Value
'Good bond cell ranges or columns
Set GBAnchorageRng = Range(ActiveCell, ActiveCell.Offset(6, 15))
Set GBAnchorageRng = Range(ActiveCell, ActiveCell.Offset(6, 15))
'Othercases (formly known as poor do not use this description bond) cell range or columns
Set OCAnchorageRng = Range(ActiveCell, ActiveCell.Offset(6, 26))
Set OCAnchorageRng = Range(ActiveCell, ActiveCell.Offset(6, 28))
On Error GoTo Handler:
'ActiveWorkbook.ActiveSheet.
Range("B93:B148").Find(What:=varLookFor, LookAt:=x1Whole = 1).Activate
'Specify range
'Range(ActiveCell.Offset(6, 0), ActiveCell.Offset(0, 31)).Select
Exit Sub
Handler:
MsgBox ("Value not found")
End Sub