Multiple Criteria & Sum VBA Code

dbnfl

Board Regular
Joined
Aug 11, 2019
Messages
59
Hello,

Hoping someone can help me with he below.



I have onemore I’m trying to add in, but I have no clue on how to do it.


Last FreeDay Sheets(1) “Data” Column B:B = (Date Value)
I Need toget a date value based on multiple criteria and sum
1st- Match Sheets(1) “Data” Column AZ (Header:Shipping Line) with Sheets(4) “Lists” Column O (Header: Shipping Line)
Once matchedmove one cell to right Sheets(4) “Lists” Column P and depending on cell value Iwant to sum
Sheets(1) “Data”Column AU (If Value of Sheets(4) Column P = First Availablility)
Or
Sheets(1) “Data”Column AX (If Value of Sheet(4) Column P = Wharf Date of Discharge)
With Valueof Sheets(4) “Lists” Column Q, R, S, T, U, V, W, X, Y, Z, AA, or AB.
Eg. Sheets(4)“Lists” Column and Container type.
Q = 20GP
R = 20HC
S = 20RF
T = 20OT
U = 20FR
V = 20TK
W = 40GP
X = 40HC
Y = 40RF
Z = 40OT
AA = 40FR
AB = 40TK

I need toreference container type from Sheets(1) “Data” Column S of that row.

Want to runwithin this code



Private Sub Worksheet_SelectionChange(ByVal Target As Range)

'my formula on worksheet =INDEX('Wharf Schedules'!B:B,MATCH(Data!AO59&Data!AQ59,'Wharf Schedules'!C:C&'Wharf Schedules'!E:E,0))

Range("AO5").FormulaArray = "=IFERROR(INDEX('Wharf Schedules'!B:B,MATCH('Data'!AR5&AT5,'Wharf Schedules'!C:C&'Wharf Schedules'!E:E,0)),"""")"
With Range("AO5:AO" & Cells(Rows.Count, "B").End(xlUp).Row)
.FillDown
.Value = .Value
End With

Range("AP5").FormulaArray = "=IFERROR(INDEX('Wharf Schedules'!G:G,MATCH('Data'!AR5&AT5,'Wharf Schedules'!C:C&'Wharf Schedules'!E:E,0)),"""")"
With Range("AP5:AP" & Cells(Rows.Count, "B").End(xlUp).Row)
.FillDown
.Value = .Value
End With

Range("AQ5").FormulaArray = "=IFERROR(INDEX('Wharf Schedules'!I:I,MATCH('Data'!AR5&AT5,'Wharf Schedules'!C:C&'Wharf Schedules'!E:E,0)),"""")"
With Range("AQ5:AQ" & Cells(Rows.Count, "B").End(xlUp).Row)
.FillDown
.Value = .Value
End With

Range("AS5").FormulaArray = "=IFERROR(INDEX('Wharf Schedules'!D:D,MATCH('Data'!AR5&AT5,'Wharf Schedules'!M:M&'Wharf Schedules'!O:O,0)),"""")"
With Range("AS5:AS" & Cells(Rows.Count, "B").End(xlUp).Row)
.FillDown
.Value = .Value
End With

Range("AU5").FormulaArray = "=IFERROR(INDEX('Wharf Schedules'!Q:Q,MATCH('Data'!AR5&AT5,'Wharf Schedules'!M:M&'Wharf Schedules'!O:O,0)),"""")"
With Range("AU5:AU" & Cells(Rows.Count, "B").End(xlUp).Row)
.FillDown
.Value = .Value
End With

Range("AV5").FormulaArray = "=IFERROR(INDEX('Wharf Schedules'!R:R,MATCH('Data'!AR5&AT5,'Wharf Schedules'!M:M&'Wharf Schedules'!O:O,0)),"""")"
With Range("AV5:AV" & Cells(Rows.Count, "B").End(xlUp).Row)
.FillDown
.Value = .Value
End With

Range("AW5").FormulaArray = "=IFERROR(INDEX('Wharf Schedules'!S:S,MATCH('Data'!AR5&AT5,'Wharf Schedules'!M:M&'Wharf Schedules'!O:O,0)),"""")"
With Range("AW5:AW" & Cells(Rows.Count, "B").End(xlUp).Row)
.FillDown
.Value = .Value
End With



End Sub




I am hopingsomeone can help me with this.


Dale.
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

Forum statistics

Threads
1,215,375
Messages
6,124,578
Members
449,174
Latest member
chandan4057

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top