Chercher la derniere valeur sur 3 colonnes

eduraiss

XLDnaute Accro
Bonjour le forum

voila sur un tableau j'ai des valeurs dans les colonnes D F H le code ci dessous me permet de me placer sous la dernière valeur de la colonne D

Columns(4).Find("*", , , , , xlPrevious).Offset(2, 0).Select

Quel brin de code me faudrait t'il pour me positionner sous la dernière valeur de ses trois colonnes et ensuite retour dans la colonne D sur la même ligne.

Je joins un fichier

Cordialement..
 

Pièces jointes

  • eric2.zip
    9.3 KB · Affichages: 28
  • eric2.zip
    9.3 KB · Affichages: 25
  • eric2.zip
    9.3 KB · Affichages: 24

wilfried_42

XLDnaute Barbatruc
Re : Chercher la derniere valeur sur 3 colonnes

bonjour edurais

essaye ce code
Code:
sub essai()
      dim cold as range, colf as range, colh as range
      set cold = range("D65536").end(xlup).offset(1,0)
      set colf = range("F65536").end(xlup).offset(1,0)
      set colh = range("H65536").end(xlup).offset(1,0)
      if cold > colf then 
             if cold > colh then
                      set colf = cold.offset(0,2)
                      set colh = cold.offset(0,4)
             else
                      set cold = colh.offset(0,-4)
                      set colf = colh.offset(0,-2)        
             end if
      else
             if colf > colh then
                      set cold = colf.offset(0,-2)
                      set colh = colf.offset(0,2)
             else
                      set cold = colh.offset(0,-4)
                      set colf = colh.offset(0,-2)        
             end if
      end if
end sub

code non tester
 

Pierrot93

XLDnaute Barbatruc
Re : Chercher la derniere valeur sur 3 colonnes

BOnsoir Eduraiss, Jean-Pierre, Wilfried

peut être comme ceci :

Code:
Dim l As Integer
l = IIf(Range("H65536").End(xlUp).Row > Range("F65536").End(xlUp).Row, Range("H65536").End(xlUp).Row, _
    Range("F65536").End(xlUp).Row)
l = IIf(Range("D65536").End(xlUp).Row > l, Range("d65536").End(xlUp).Row, l)
Range("D" & l + 1).Select

bonne soirée
@+
 

wilfried_42

XLDnaute Barbatruc
Re : Chercher la derniere valeur sur 3 colonnes

re:

excuse moi eduraiss j'ai oublié les .row

Code:
Sub essai()
      Dim cold As Range, colf As Range, colh As Range
      Set cold = Range("D65536").End(xlUp).Offset(1, 0)
      Set colf = Range("F65536").End(xlUp).Offset(1, 0)
      Set colh = Range("H65536").End(xlUp).Offset(1, 0)
      If cold.Row > colf.Row Then
             If cold.Row > colh.Row Then
                      Set colf = cold.Offset(0, 2)
                      Set colh = cold.Offset(0, 4)
             Else
                      Set cold = colh.Offset(0, -4)
                      Set colf = colh.Offset(0, -2)
             End If
      Else
             If colf.Row > colh.Row Then
                      Set cold = colf.Offset(0, -2)
                      Set colh = colf.Offset(0, 2)
             Else
                      Set cold = colh.Offset(0, -4)
                      Set colf = colh.Offset(0, -2)
             End If
      End If
      MsgBox cold.Address & vbCrLf & colf.Address & vbCrLf & colh.Address
End Sub

quand on quitte le boulot de nuit, on ferait mieux de dormir :(
 

Discussions similaires

Membres actuellement en ligne

Statistiques des forums

Discussions
312 277
Messages
2 086 716
Membres
103 378
dernier inscrit
phdrouart