Multiple Range VBA and search/replace

Celticfc

Board Regular
Joined
Feb 28, 2016
Messages
153
Hi all,

I'm trying to enter array formula to 2x hidden sheets and then do a replacement (as the array is over 255 characters) and then break links so that I can have it all as values.

1) it only works for the first part of the range (a2:a150), any chance I can apply the macro to all ranges done in one go?
2) is there a way to tidy up the macro and narrow it down?

code:
Code:
Sub Macro2()
  Dim wb As Workbook
Set wb = Application.ActiveWorkbook
  
 'first sheet - multiple range

  Sheets("ltis").Range("a2:a150, e2:j150, au2:ax150, ch2:ci150, cl2:cm150").FormulaArray = _
"=IFERROR(INDEX('https:/PATH/[el.xlsx]formulationsTK'!$A:$CX,SMALL(IF('https:/PATH/[el.xlsx]formulationsTK'!$B:$B=filter,ROW($B:$B)),ROW()),COLUMN()),"""")"
    
Sheets("ltis").Cells.Replace What:="PATH", Replacement:= _
        "/klxs/sharepoint.com/sites/Shared Documents"

'second sheet - single range

Sheets("klpn").Range("a2:e150").FormulaArray = _
"=IFERROR(INDEX('https:/PATH/[el.xlsx]formulationsTK'!$A:$CX,SMALL(IF('https:/PATH/[el.xlsx]formulationsTK'!$B:$B=filter,ROW($B:$B)),ROW()),COLUMN()),"""")"

Sheets("klpn").Cells.Replace What:="PATH", Replacement:= _
        "/klxs/sharepoint.com/sites/Shared Documents"
        
        
If Not IsEmpty(wb.LinkSources(xlExcelLinks)) Then
    For Each link In wb.LinkSources(xlExcelLinks)
        wb.BreakLink link, xlLinkTypeExcelLinks

    Next link

End If
End Sub
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

Forum statistics

Threads
1,215,436
Messages
6,124,869
Members
449,192
Latest member
MoonDancer

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