Showing posts with label VBA. Show all posts
Showing posts with label VBA. Show all posts

Thursday, July 14, 2011

VBA excel - sheets exist ?

The function:
Public Function SheetExists(SheetName As String) As Boolean
    Dim ws As Worksheet
    SheetExists = False
    For Each ws In ThisWorkbook.Worksheets
        If ws.Name = SheetName Then SheetExists = True
    Next ws
End Function
create sheet if it does not exist:
For i = 1 to n
    If SheetExists("Sheet" & CStr(i)) Then
        MsgBox ("Sheet" & CStr(i) & " exists")
    Else
        Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = "Sheet" & CStr(i)
    End If
Next i

Wednesday, April 6, 2011

VBA-Error "Run-time error'-2147467259 (80004005)': Method 'Add of object 'CommandBar Controls' failed".

You have a faulting add-in. Go to Office Button>Excel Options...>Add-ins and
uncheck all then add one at a time back in and re-start excel when the issue
comes back,that's your issue.

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
nick_hodgeTAKETHISOUT

from here.