ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Execute code in a loop - Question (https://www.excelbanter.com/excel-programming/411707-execute-code-loop-question.html)

Les

Execute code in a loop - Question
 
Hello all, i am not a programmer so forgive the type of questions. Is it
possible to run code to manipulate a document if it is opened within a loop
and once finished the loop continues ?
--
Les

Sam Wilson

Execute code in a loop - Question
 
Hi Les, yes it is:

sub demo()

dim wb as work book
dim s as string
dim i as integer

s= "C:\Filepath\File.xls"

for i = 1 to 10
Set wb = Workbooks.Open(s, False)

'Write your code in here

wb.Close
next i

end sub


"Les" wrote:

Hello all, i am not a programmer so forgive the type of questions. Is it
possible to run code to manipulate a document if it is opened within a loop
and once finished the loop continues ?
--
Les


Les

Execute code in a loop - Question
 
Thanks Sam, much appreciated
--
Les


"Sam Wilson" wrote:

Hi Les, yes it is:

sub demo()

dim wb as work book
dim s as string
dim i as integer

s= "C:\Filepath\File.xls"

for i = 1 to 10
Set wb = Workbooks.Open(s, False)

'Write your code in here

wb.Close
next i

end sub


"Les" wrote:

Hello all, i am not a programmer so forgive the type of questions. Is it
possible to run code to manipulate a document if it is opened within a loop
and once finished the loop continues ?
--
Les



All times are GMT +1. The time now is 11:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com