spliting the array formula

kelvin_9

Active Member
Joined
Mar 6, 2015
Messages
444
Office Version
  1. 2019
i was amended a formula here and planning to run in macro, but i got stuck
is it mean one more range need to assign to run the new formula?

Code:
Sub Macro003()'
' Macro003 Macro
'




'
    Sheets("result").Select
    Dim rDate As Range, rDest As Range
    Dim sText1 As String, sText2 As String




    Set rDate = Range("c50")
    Set rDest = Range("c51")




    sText1 = "TEXT(MIN(IFERROR(TIMEVALUE(LEFT(INDEX('schedule'!$C:$C,MATCH('result'!$A51,'schedule'!$A:$A,0)):INDEX('schedule'!$C:$C,MATCH('result'!$A52,'schedule'!$A:$A,0)-1),5)),1)),""hh:mm"")"
    sText2 = "TEXT(MAX(IFERROR(TIMEVALUE(MID(INDEX('schedule'!$C:$C,MATCH('result'!$A51,'schedule'!$A:$A,0)):INDEX('schedule'!$C:$C,MATCH('result'!$A52,'schedule'!$A:$A,0)-1),7,5)),0)),""hh:mm"")"




    rDest.FormulaArray = "=IF(INDEX('schedule'!$C:$C,MATCH('result'!$A51,'schedule'!$A:$A,0))="""","""",1111&"" - ""&2222)"
    rDest.Replace "1111", sText1, LookAt:=xlPart
    rDest.Replace "2222", sText2, LookAt:=xlPart




    Range("c51").AutoFill Destination:=Range("c51:c" & Range("a" & Rows.Count).End(xlUp).Row)




    Range("b51").Select
    ActiveCell.FormulaR1C1 = _
        "=IFERROR((VLOOKUP(RC1,'availability'!C1:C23,5,FALSE)),"""")"
    Range("b51").AutoFill Destination:=Range("b51:b" & Range("a" & Rows.Count).End(xlUp).Row)




End Sub

Code:
=IF(INDEX(SCHEDULE!$C:$C,MATCH(RESULT!$A51,SCHEDULE!$A:$A,0))="","",if(TEXT(MIN(IFERROR(TIMEVALUE(LEFT(INDEX(SCHEDULE!$C:$C,MATCH(RESULT!$A51,SCHEDULE!$A:$A,0)):INDEX(SCHEDULE!$C:$C,MATCH(RESULT!$A52,SCHEDULE!$A:$A,0)-1),5)),1)),"hh:mm")="00:00",INDEX(SCHEDULE!$C:$C,MATCH(RESULT!$A51,SCHEDULE!$A:$A,0)),TEXT(MIN(IFERROR(TIMEVALUE(LEFT(INDEX(SCHEDULE!$C:$C,MATCH(RESULT!$A51,SCHEDULE!$A:$A,0)):INDEX(SCHEDULE!$C:$C,MATCH(RESULT!$A52,SCHEDULE!$A:$A,0)-1),5)),1)),"hh:mm")&" - "&TEXT(MAX(IFERROR(TIMEVALUE(MID(INDEX(SCHEDULE!$C:$C,MATCH(RESULT!$A51,SCHEDULE!$A:$A,0)):INDEX(SCHEDULE!$C:$C,MATCH(RESULT!$A52,SCHEDULE!$A:$A,0)-1),7,5)),0)),"hh:mm")))
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Code:
Sub Test()Dim rDate As Range, rDest As RangeDim sText1 As String, sText2, sText3 As String


Set rDate = Range("a1")
Set rDest = Range("a2")


sText1 = "TEXT(MIN(IFERROR(TIMEVALUE(LEFT(INDEX(schedule!$C:$C,MATCH(result!$A51,schedule!$A:$A,0)):INDEX(schedule!$C:$C,MATCH(result!$A52,schedule!$A:$A,0)-1),5)),1)),""hh:mm"")=""00:00"""
sText2 = "TEXT(MIN(IFERROR(TIMEVALUE(LEFT(INDEX(schedule!$C:$C,MATCH(result!$A51,schedule!$A:$A,0)):INDEX(schedule!$C:$C,MATCH(result!$A52,schedule!$A:$A,0)-1),5)),1)),""hh:mm"")"
sText3 = "TEXT(MAX(IFERROR(TIMEVALUE(MID(INDEX(schedule!$C:$C,MATCH(result!$A51,schedule!$A:$A,0)):INDEX(schedule!$C:$C,MATCH(result!$A52,schedule!$A:$A,0)-1),7,5)),0)),""hh:mm"")"


rDest.FormulaArray = "=IF(INDEX(schedule!$C:$C,MATCH(result!$A51,schedule!$A:$A,0))="""","""",if(1111,INDEX(SCHEDULE!$C:$C,MATCH(RESULT!$A51,SCHEDULE!$A:$A,0)),2222&""-""&3333)"
rDest.Replace "1111", sText1, LookAt:=xlPart
rDest.Replace "2222", sText2, LookAt:=xlPart
rDest.Replace "3333", sText3, LookAt:=xlPart


End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,520
Messages
6,120,013
Members
448,935
Latest member
ijat

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