Hello everybody. and Govert. I am writing this time to ask if it is possible to adaptate or convert a VBA Function into a VB Function in .NET and aggregate it into an Excel DNA AddInn. And if it is possible, how can I do that? The functions are two, one of them is to aggregate a new Excel sheet with a name that you can give and the other one finds a worksheet with the same name. her is the code:
Function BuscarHoja1(nombreHoja As String) As Boolean
'Esta función devuelve un valor verdadero o falso para una variable que verifica si existe
'una hoja por la cual se pregunte en un momento que se requiera
For i = 1 To Worksheets.Count
If Worksheets(i).Name = nombreHoja Then
BuscarHoja1 = True
Exit Function
End If
Next
BuscarHoja1 = False
End Function
Function CrearHoja(nombreHoja As String) As Boolean
'Esta función permite crear una hoja nueva verificando el nombre de manera tal que no de
'error de creacion de hoja
Dim existe As Boolean
On Error Resume Next
existe = (Worksheets(nombreHoja).Name <> "")
If Not existe Then
Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = nombreHoja
End If
CrearHoja = existe
End Function
on visual studio give me an error of compilation, in the instruction WorkSheets
If anybody can help me? Thanks a lot.