Using VBA Compiler with currentregion

jav2110

New member
Could you helpe me to implement this function with vba compiler, I get an error in line 7:

Function DeterminaRango(ByVal rgCelda As Range, ByVal intTipo As Integer) As Range
Code:
'0 Determina el rango con encabezados
'1 Determina el rango sin encabezados

Dim rgDatos As Range
Set rgDatos = rgCelda.CurrentRegion

If intTipo = 1 Then
    Set rgDatos = rgDatos.Offset(1).Resize(rgDatos.Rows.Count - 1)
End If
Set DeterminaRango = rgDatos
End Function
 
All Excel objects must be invoked by using Application DOT.
Try this:
Code:
Function DeterminaRango(ByVal rgCelda As String, ByVal intTipo As Integer) As String
    Dim rgDatos As Object
  
    ' Récupérer l'objet Excel via XLS Padlock
     Set rgDatos = Application.Range(rgCelda).CurrentRegion

    ' Vérifier si on doit exclure les en-têtes
    If intTipo = 1 Then
        Set rgDatos = rgDatos.Offset(1).Resize(rgDatos.Rows.Count - 1)
    End If

    ' Retourner l'adresse de la plage comme une chaîne de caractères
    DeterminaRango = rgDatos.Address
End Function
 
Back
Top