Vendredi 29 janvier 2010 5 29 /01 /Jan /2010 16:18
Sub LONGUEUR_MAX_UNE_COLONNE()
'
'
'
Dim WS As Worksheet
Dim i As Integer
Dim com As String
Dim col As String

' parcours tous les cellules d'une colonne et retourne la taille maximale trouvée,  :

col = InputBox("Entrez le nom de la colonne (A,B,...)", "Colonne", "A")
i = 0
For n = 1 To Rows.Count
     If i < Len(Cells(n, col).Value) Then i = Len(Cells(n, col).Value)
Next n
   MsgBox ("longueur maxi de " & col & " : " & i)
End Sub
Sub LONGUEUR_MAX_TOUTES_COLONNES()
'
'
'
Dim WS As Worksheet
Dim i As Integer
Dim com As String
Dim col As String

' parcours toutes les cellules de toutes les colonnes
' et retourne la taille maximale trouvée
' on ne tient pas compte de la première ligne qui contient les titres

com = "  longueur maxi de "
For m = 1 To ActiveSheet.UsedRange.Columns.Count
  i = 0
  For n = 2 To ActiveSheet.UsedRange.Rows.Count
     If i < Len(Cells(n, m).Value) Then i = Len(Cells(n, m).Value)
  Next n
  com = com & "  " & Chr(64 + m) & " : " & i & " - "
Next m
MsgBox (com)
End Sub
Par memoprog - Publié dans : VISUALBASIC
Ecrire un commentaire - Voir les 0 commentaires
Retour à l'accueil

Présentation

Créer un Blog

Recherche

Calendrier

Mai 2012
L M M J V S D
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
<< < > >>
Créer un blog gratuit sur over-blog.com - Contact - C.G.U. - Rémunération en droits d'auteur - Signaler un abus