LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default how can I see if an array contain a certain variable?

Ronaldo wrote:
Hi,

At least do I belive I should use arrays to solve it, but did sleep during
the array part of the course:-)

In an Worksheet_Deactivate event, I want to compare if the Target range is
into one of my known sheets or if it is an unknown sheet. This will make me
know if Target is another workbook, since there will be no more sheets in my
workbook. I thought of running a loop through my array with 13 woorksheets
and see if the "ActiveWorksheet" is there.

I have started to give name the arrays like:

shtArray(0) = Sheet1.Name
shtArray(1) = Sheet2.Name
:
and thought of running a Loop like:
"If ActiveSheet.Name < shtArray" Then

I has been thinking about using woorkbook_deactivate event, but can't find
out how i can get the Target range and continue with my code in a right
way.

Better ways to solve it are of course welcome, but maybe this give me a
reason to learn arrays once and for all:-)


- Regards -


You might want to consider adding a reference to Microsoft Scripting
Runtime and using something like

Sub qwerty1()
Dim x As Dictionary, i As Long
Set x = New Dictionary
For i = 1 To Worksheets.Count
x.Add Item:=Worksheets(i).Name, key:=CStr(Worksheets(i).Name)
Next
If x.Exists("Sheet3") Then
'Do whatever
Else
'Do whatever else
End If
End Sub

Alan Beban
 
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
Using COUNTA for a variable array Schannah Excel Worksheet Functions 5 July 22nd 08 05:02 PM
use a variable array in a formula JPderose Excel Discussion (Misc queries) 1 October 20th 05 06:24 AM
about ARRAY variable Marek Excel Programming 3 September 13th 04 06:40 PM
Variable Array Problem mudraker[_37_] Excel Programming 3 November 26th 03 12:43 AM
Problem trying to us a range variable as an array variable TBA[_2_] Excel Programming 4 September 27th 03 02:56 PM


All times are GMT +1. The time now is 02:38 PM.

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

About Us

"It's about Microsoft Excel"