LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default Verify if sheet name still exist

To each & everyone of u who responded, I sincerely thank you very very much.

Especially to those of u who put in so much extra effort in explaining &
putting indicators in your code to guide me, I'm really really touched.

Your spirit, effort & contribution is benefiting many.

--
Edmund
(Using Excel XP)


"Dove" wrote:

Edmund,

Actually by using the keyword of "Sheets" you are technically using an
array... It is actually defined as a collection, but works just like an
array you would define yourself. The following code demonstrates how
"Sheets" is a single dimensional array:

Dim i as Ineger

For i = 1 to Sheets.Count
MsgBox Sheets(i).Name
Next i

VB(A) provides many default 'arrays' of things which it calls "Collections".
In the code you used, you just can't see how Sheets is used as an array
because of the way you use the keyword...

Private Sub DoesSheetExist()
Dim n As Variant
Do While ActiveCell < ""
For Each n In Sheets
If ActiveCell.Value = n.Name Then _
ActiveCell.Offset(0, 1) = "Present"
Next n
ActiveCell.Offset(1, 0).Select
Loop
End Sub


This could be translated as:

Private Sub DoesSheetExist()
Dim i as Integer
Dim s as Integer
Dim temp as String

For i = 1 to ActiveSheet.UsedRange.Rows.Count ' Change 1 to 2 if row 1
is a header
temp = Cells(i,1).Value ' Assuming column 1 has the names...
For s = 1 to Sheets.Count
If Sheets(s).Name = temp then
Cells(i,2).Value = "Present"
Exit For
End If
Next s
If s Sheets.Count Then Cells(i,2).Value = "NOT Present" 'addition
to original code...
Next i
End Sub

Technically, "Cells" is a two dimensional array of the cells on the active
worksheet!

David


"Edmund" wrote in message
...
Dear Tim,

I wrote the below sample code. It served the purpose in identifying if the
sheets exist. But because I'm a learner (self study), I was not satisfied
with this below approach as I actually intend to use the "computer's
memory"
to remember the names of all the existing sheet name, then cycle through
these memorized names to see if any matches that in the activecell of
Column
A Sheet1. So, I thought the word was "array". I wanted to learn more.

Though my below procedure serves the purpose by cycling via For-Next, I'm
still ignorant on how to utilize computer's memory. I've searched my VBA
book
& also F1 Help but can't find an appropriate example to grasp. Perhaps, I
hv
not understood how to use array yet. That's why I wanted a sample in
array(if
any), instead of just the usual For-Next.

My calamity:
I hv absolutely no programming background nor any friends nor colleagues
who
can help with "Excel VBA". Absolutely no one to ask. Infact, I know very
little about any applications except with MS Excel (but not in VBA. Still
self studying). And though I work for a very big & prominent company with
7000 workforce, which includes many good & skilled programmers (mainly VB
&

VB.net), but absolutely non of them has the slightest knowledge on Excel
VBA
(Excel VBA is something almost unheard of in this part of the world, even
to
IT people. No one talks about Excel VBA because non hv realized its
potential).

Hope that explains.
Good day.


Private Sub DoesSheetExist()
Dim n As Variant
Do While ActiveCell < ""
For Each n In Sheets
If ActiveCell.Value = n.Name Then _
ActiveCell.Offset(0, 1) = "Present"
Next n
ActiveCell.Offset(1, 0).Select
Loop
End Sub

--
Edmund
(Using Excel XP)


"Tim Williams" wrote:

Why an array?

Tim

"Edmund" wrote in message
...
If possible, it will be excellent if you can demonstrate it with an
array.

--
Edmund
(Using Excel XP)







 
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
verify if spesific sheet exist Miri Excel Discussion (Misc queries) 3 February 26th 07 01:04 PM
Verify if a workbook exist with a macro Homero Excel Programming 1 October 1st 05 06:46 PM
Verify if Comment exist in a cell Tom LeBold Excel Discussion (Misc queries) 2 September 15th 05 08:47 PM
Does the sheet exist? Dr.Schwartz Excel Programming 1 August 25th 04 02:16 PM
Does sheet exist? Sean Evanovich Excel Programming 2 November 19th 03 02:30 PM


All times are GMT +1. The time now is 02:47 AM.

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"