View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default If Sheet Exists Q

From my reading of the code it is not doing what you say, but it does
process a sheet called Log.

This code

newShtName = Format([a5], "dd-mm-yy")

is very bad code IMO. By using short cut range notation, it ALWAYS works on
the activesheet. This may be what is required, but far batter to be explicit
so everyone knows

newShtName = Format(Activesheet.range("A5").Value, "dd-mm-yy")

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Sean" wrote in message
...
Right again Bob! I copied from another piece of code I had and never
copied this

Private Function SheetExists(sname) As Boolean
'from John Walkenbach
Dim x As Object
On Error Resume Next
Set x = ActiveWorkbook.Sheets(sname)
If Err = 0 Then SheetExists = True _
Else SheetExists = False
End Function

Q - How it seems to work (which is not how I want it to work) is If
the sheet exists it just copies to a new sheet and re-names as "log
(2)". What I thought my code did, is take the value of A5 and see if a
sheet name exists of that, if it does exist - show a msb box, if it
does,'t create a new copy sheet called - the value in A5 (in format)
dd-mm-yy.