Un truc sûrement simple, mais je galère, j'ai fait une fonction qui
retourne
la première ligne vide d'une colonne passée en paramètre, OK c'est bon.
J'aimerais aussi passer en paramètre le nom d'une feuille, mais voilà
je n'y arrive pas
-----------------------------------------------------------------
Function Premiere_ligne_vide_Colonne(C As String) As Integer
Dim Lig As Long
Lig = 1
Do While Not IsEmpty(Range(C & Lig))
Lig = Lig + 1
Loop
Premiere_ligne_vide_Colonne = Lig
End Function
----------------------------------------------
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
MichD
Le 21/déc./2018 à 12:36, Brat'ac a écrit :
----------------------------------------------------------------- Function Premiere_ligne_vide_Colonne(C As String) As Integer Dim Lig As Long Lig = 1 Do While Not IsEmpty(Range(C & Lig)) Lig = Lig + 1 Loop Premiere_ligne_vide_Colonne = Lig End Function ----------------------------------------------
Bonjour, '-------------------------- Sub test() '7 = numéro de la colonne 'Feuil1 = nom de l'onglet de la feuille MsgBox LastRow(7, "Feuil1") End Sub '----------------------------------- Function LastRow(C As Long, NomFeuille As String) As Long With Worksheets(NomFeuille) LastRow = .Cells(.Rows.Count, C).End(xlUp).Row If .Cells(LastRow, C) <> "" Then LastRow = LastRow + 1 End If End With End Function '----------------------------------- MichD
Le 21/déc./2018 à 12:36, Brat'ac a écrit :
-----------------------------------------------------------------
Function Premiere_ligne_vide_Colonne(C As String) As Integer
Dim Lig As Long
Lig = 1
Do While Not IsEmpty(Range(C & Lig))
Lig = Lig + 1
Loop
Premiere_ligne_vide_Colonne = Lig
End Function
----------------------------------------------
Bonjour,
'--------------------------
Sub test()
'7 = numéro de la colonne
'Feuil1 = nom de l'onglet de la feuille
MsgBox LastRow(7, "Feuil1")
End Sub
'-----------------------------------
Function LastRow(C As Long, NomFeuille As String) As Long
With Worksheets(NomFeuille)
LastRow = .Cells(.Rows.Count, C).End(xlUp).Row
If .Cells(LastRow, C) <> "" Then
LastRow = LastRow + 1
End If
End With
End Function
'-----------------------------------
----------------------------------------------------------------- Function Premiere_ligne_vide_Colonne(C As String) As Integer Dim Lig As Long Lig = 1 Do While Not IsEmpty(Range(C & Lig)) Lig = Lig + 1 Loop Premiere_ligne_vide_Colonne = Lig End Function ----------------------------------------------
Bonjour, '-------------------------- Sub test() '7 = numéro de la colonne 'Feuil1 = nom de l'onglet de la feuille MsgBox LastRow(7, "Feuil1") End Sub '----------------------------------- Function LastRow(C As Long, NomFeuille As String) As Long With Worksheets(NomFeuille) LastRow = .Cells(.Rows.Count, C).End(xlUp).Row If .Cells(LastRow, C) <> "" Then LastRow = LastRow + 1 End If End With End Function '----------------------------------- MichD
MichD
Le 21/déc./2018 à 12:56, MichD a écrit :
Le 21/déc./2018 à 12:36, Brat'ac a écrit :
----------------------------------------------------------------- Function Premiere_ligne_vide_Colonne(C As String) As Integer Dim Lig As Long Lig = 1 Do While Not IsEmpty(Range(C & Lig)) Lig = Lig + 1 Loop Premiere_ligne_vide_Colonne = Lig End Function ----------------------------------------------
On peut faire aussi comme ceci en modifiant le type de variable '------------------------ Sub test() '7 numéro de la colonne 'feuil1 est la propriété Name de l'objet Feuille MsgBox LastRow(7, Feuil1) End Sub '------------------------ Function LastRow(C As Long, Feuille As Worksheet) As Long With Feuille LastRow = .Cells(.Rows.Count, C).End(xlUp).Row If .Cells(LastRow, C) <> "" Then LastRow = LastRow + 1 End If End With End Function '------------------------ MichD
Le 21/déc./2018 à 12:56, MichD a écrit :
Le 21/déc./2018 à 12:36, Brat'ac a écrit :
-----------------------------------------------------------------
Function Premiere_ligne_vide_Colonne(C As String) As Integer
Dim Lig As Long
Lig = 1
Do While Not IsEmpty(Range(C & Lig))
Lig = Lig + 1
Loop
Premiere_ligne_vide_Colonne = Lig
End Function
----------------------------------------------
On peut faire aussi comme ceci en modifiant le type de variable
'------------------------
Sub test()
'7 numéro de la colonne
'feuil1 est la propriété Name de l'objet Feuille
MsgBox LastRow(7, Feuil1)
End Sub
'------------------------
Function LastRow(C As Long, Feuille As Worksheet) As Long
With Feuille
LastRow = .Cells(.Rows.Count, C).End(xlUp).Row
If .Cells(LastRow, C) <> "" Then
LastRow = LastRow + 1
End If
End With
End Function
'------------------------
----------------------------------------------------------------- Function Premiere_ligne_vide_Colonne(C As String) As Integer Dim Lig As Long Lig = 1 Do While Not IsEmpty(Range(C & Lig)) Lig = Lig + 1 Loop Premiere_ligne_vide_Colonne = Lig End Function ----------------------------------------------
On peut faire aussi comme ceci en modifiant le type de variable '------------------------ Sub test() '7 numéro de la colonne 'feuil1 est la propriété Name de l'objet Feuille MsgBox LastRow(7, Feuil1) End Sub '------------------------ Function LastRow(C As Long, Feuille As Worksheet) As Long With Feuille LastRow = .Cells(.Rows.Count, C).End(xlUp).Row If .Cells(LastRow, C) <> "" Then LastRow = LastRow + 1 End If End With End Function '------------------------ MichD
Brat'ac
MichD avait énoncé : Super c'est parfait. Merci et bonne fêtes de fin d'année !
MichD avait énoncé :
Super c'est parfait.
Merci et bonne fêtes de fin d'année !