View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
kevlarmcc kevlarmcc is offline
external usenet poster
 
Posts: 11
Default Strange probem with capitalization of object

I thought I was choosing to use the object itself rather than a variable for
it. I get the same results with using a variable such as "ws". Thanks for the
help, as I am new to this. What's second?

"Dave Peterson" wrote:

First, using a variable named Worksheet is a bad idea. Excel has an object that
uses that name (it's a worksheet <vbg.)

Instead

Option Explicit
Sub RunAll()
dim wks as worksheet
for each wks in worksheets
case "Report 1"
......



kevlarmcc wrote:

I have two copies of code that I swear are indentical except for the
captialization of an object, which seems to be automatic. Somehow one copy of
the code doesn't auto cap the object and it is that copy that works. Code is
below:

Sub RunAll()

For Each Worksheet In Worksheets
Select Case Worksheet.Name
Case "Report 1"
Case Else
Worksheet.Activate
If ActiveSheet.Name = "BGE" Then _
ActiveSheet.Name = "Sheet999"
End Select
Next Worksheet
End Sub

When Name is capped, it doesn't work. With lowercase name it works. I can't
seem to replicate the non-capped object because when writing new code it
won't let me not capitalize it. I am not sure what I did to get the object
not capitalized in the first place. Anyone understand this?


--

Dave Peterson
.