Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
how can I see if an array contain a certain variable?
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 - |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
how can I see if an array contain a certain variable?
Hi
but why do you want to check this?. If you only want to make sure that it is not the same workbook why not compare the workbook objects? -- Regards Frank Kabel Frankfurt, Germany "Ronaldo" schrieb im Newsbeitrag ... 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 - |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
how can I see if an array contain a certain variable?
You've lost me mate. What is the Target Range in this instance?
If you just wasn't to see if a worksheet contains a specific worksheet, there are easier ways. -- HTH RP (remove nothere from the email address if mailing direct) "Ronaldo" wrote in message ... 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 - |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Using COUNTA for a variable array | Excel Worksheet Functions | |||
use a variable array in a formula | Excel Discussion (Misc queries) | |||
about ARRAY variable | Excel Programming | |||
Variable Array Problem | Excel Programming | |||
Problem trying to us a range variable as an array variable | Excel Programming |