#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default 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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Answers to questions posing more questions in a workbook sbelle1 Excel Worksheet Functions 2 August 8th 09 01:02 AM
View Questions and Answer to questions I created Roibn Taylor Excel Discussion (Misc queries) 4 July 24th 08 12:05 AM
2 questions again Bob L. Excel Programming 11 September 29th 03 09:55 PM
2 questions john petty Excel Programming 0 September 29th 03 04:21 PM
VB questions Dick Kusleika Excel Programming 0 September 4th 03 09:20 PM


All times are GMT +1. The time now is 11:19 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"