Go to initial workbook (with VBA do until) after closing second workbook

NDWA

New Member
Joined
Apr 13, 2023
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hello

I have a workbook with a list of ISO-codes (from A2 till A138)
De cell A2 is selected.
In the vba code I ask to open a template run the auto open macro (get data - save as and close this file)
and then in the initial file I want to delete row 2 and repeat the actions until we are at the end of the list.
But the vba stops when the template did the save as and close the file.
What do I have to do to continue the vba in the initial file ?
Thanks for helping !

this is the VBA in the initial file :

Sub Scorecalculation2()

Dim ThisWkbkNm As String
ThisWkbkNm = ActiveWorkbook.Name

' Select cell A2, *first line of data*.
Range("A2").Select
' Set Do loop to stop when an empty cell is reached.

Do Until IsEmpty(ActiveCell)

ChDir "M:\RM\Country Risk\Data\MacroFiches\CRAM templates and critical values"
Workbooks.Open Filename:= _
"M:\RM\Country Risk\Data\MacroFiches\CRAM templates and critical values\RISK_score_OECD - CRAM_PROTOTYPEtest.xlsm" _
, UpdateLinks:=3

Workbooks(ThisWkbkNm).Activate
Rows(2).EntireRow.Delete
Loop
End Sub


This is the list in the initial file :
1681390529297.png
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
I think this may be as simple as adding this
Range("A2").Select
again
after
Rows(2).EntireRow.Delete
 
Upvote 0
I did it but the vba stopped already before deleting row 2.
 
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,314
Members
452,634
Latest member
cpostell

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