The control exists the sub procedure the moment it opens the workbook and throws the error as select method of Range class failed without executing the statements below the workbooks.open as shown below.
Dim FileToOpenAll As Variant
Dim SelectedIMRObook As String
Dim oWorkbook As New Workbook
Dim lastrowIMRObook As Long
SelectedIMRObook = "C:\Users\mahima.r\OneDrive\Automations\Hul Feb\testing\Templates\B_test_Soup.xlsx"
Set oWorkbook = Workbooks.Open(SelectedIMRObook)
oWorkbook.Activate
oWorkbook.Sheets(1).Range("A2").Select
lastrowIMRObook = Range("A" & Rows.Count).End(xlUp).Row
Range("a2:h" & lastrowIMRObook).Select
Selection.ClearContents