![]() |
2 questions
Hello gurus
1) How to programmatically check if a workbook is protected or not? 2) Does the For ...To .. Next loop have a syntax where I could run 2 different number ranges in the same loop. I will illustrate my question by a fake "code". For n = 1 To 10 And For n = 21 To 30 ... do this Next n I came up with an idea where I would inside the loop, use an IF condition at the beginning and let the loop ignore part of the numbers, but maybe there is a direct way also. ----------------------------------- All the best, and thanks in advance. Uno Kõrsmaa |
2 questions
Hi Uno,
Question 2 Not AFAIK however, you could try For N = 1 to 30 'do some thing If N =10 then N = 20 Next regards, Don "uno@korsmaa" wrote in message ... Hello gurus 1) How to programmatically check if a workbook is protected or not? 2) Does the For ...To .. Next loop have a syntax where I could run 2 different number ranges in the same loop. I will illustrate my question by a fake "code". For n = 1 To 10 And For n = 21 To 30 ... do this Next n I came up with an idea where I would inside the loop, use an IF condition at the beginning and let the loop ignore part of the numbers, but maybe there is a direct way also. ----------------------------------- All the best, and thanks in advance. Uno Kõrsmaa |
2 questions
1) See the answer to Sheldon's "Worksheet Protection" thread.
2) One way: For n = 1 To 30 If n <= 10 Or n=21 '... do this End If Next n an alternate is to adjust n within the loop, but I don't recommend it on general good programming principles: For n = 1 To 30 '...do this If n = 10 Then n = 20 Next n Doing a null loop as in the first example won't take more than a few microseconds. In article , "uno@korsmaa" wrote: Hello gurus 1) How to programmatically check if a workbook is protected or not? 2) Does the For ...To .. Next loop have a syntax where I could run 2 different number ranges in the same loop. I will illustrate my question by a fake "code". For n = 1 To 10 And For n = 21 To 30 ... do this Next n I came up with an idea where I would inside the loop, use an IF condition at the beginning and let the loop ignore part of the numbers, but maybe there is a direct way also. ----------------------------------- All the best, and thanks in advance. Uno Kõrsmaa |
All times are GMT +1. The time now is 06:51 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com