• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Testing with F8

vasim

Member
Hi,


I am testing the below code through F8 option, however each time I reach on Workbooks.open the further code runs automatically (without pressing F8) and ends...

Any ideas....I want to go through F8 F8 to check in each of the workbook.

[pre]
Code:
Sub update()

Dim myfolder, myfile As Variant
Dim rng, metarng As Range
Dim wsm, wsr As Worksheet
Dim awb, rwb As Workbook
Application.ScreenUpdating = False

Set wsm = Worksheets("Metadata")
Set wsr = Worksheets("data")
Set rng = wsr.Range("A1:A11")
Set awb = Workbooks("METADATA")

myfolder = "workaholixnewVOL3Reports"

For Each cell In rng
myfile = cell.Value
Set rwb = Workbooks.Open(filename:=myfolder & "" & "Name_" & myfile & ".xlsm")

rwb.Activate
rwb.Worksheets("Calc").Range("AJ:AR").Clear
awb.Worksheets("Metadata").Range("A1").CurrentRegion.Copy Sheets("Calc").Range("AJ1")
rwb.Save
rwb.Close
Next cell
Application.ScreenUpdating = True
End Sub
[/pre]
 
@Indian,


click on the line rwb.Activate


Now press F9, this will place a breakpoint on the code and it will stop here, from where you can resume pressing F8 key.


~VijaySharma
 
@Indian,


Does the RWB workbook have any macro's in it, that would run automatically when opened ?


Secondly, Can you re-write the code so that you don't activate the workbook?


eg:

Set rwb = Workbooks.Open(filename:=myfolder & "" & "Name_" & myfile & ".xlsm")


'rwb.Activate

rwb.Worksheets("Calc").Range("AJ:AR").Clear

awb.Worksheets("Metadata").Range("A1").CurrentRegion.Copy rwb.Sheets("Calc").Range("AJ1")

rwb.Save

rwb.Close
 
Thanks Hui...as usual...on the spot....


rwb has some macro on opening.....


Thanks Vijay as well...
 
Back
Top