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

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
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,214,848
Messages
6,121,917
Members
449,055
Latest member
KB13

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