After a long try and error, I finally coded it myself hehe. For the sake
of knowledge, here's the answer to the problem I described. Note that
the first 2 loopings are there to calculate the dynamic range of rows
in each of the two sheets. If anyone thinks there's something to
improve in that code, feel free to tell me. I am always trying to code
in a better way.
Regards,
Werner
Code:
--------------------
Sub Mise_a_jour_Sources()
Dim e As Long
Dim H As Long
Dim L As Long
Dim i As Long
Dim j As Long
' Variable qui sert à savoir s'il y a des PI à supprimer.
Dim Pi_Check As Long
Pi_Check = 0
Dim lstRw As Long
Dim lstRwForm As Long
'Vérification s'il y a des PI.
With Worksheets("PI")
For e = 16 To 25
If Range("A" & e).Value = "" Then
'Rien
Else
Pi_Check = Pi_Check + 1
End If
Next e
End With
If Pi_Check = 0 Then
lstRw = 8
Else
'Je détermine le nombre de ligne d'unité locative que j'ai.
Let lstRw = Sheets("PI").Range("a65536").End(xlUp).Row
End If
Pi_Check = 0
With Worksheets("Formulaire")
For H = 16 To 25
If Range("A" & H).Value = "" Then
'Rien
Else
Pi_Check = Pi_Check + 1
End If
Next H
End With
If Pi_Check = 0 Then
lstRw = 8
Else
'Je détermine le nombre de ligne d'unité locative que j'ai.
Let lstRwForm = Sheets("Formulaire").Range("a65536").End(xlUp).Row
MsgBox lstRwForm
End If
'On met à jour l'information UE
'Acces_dossier
Sheets("PI").Select
Worksheets("PI").Range("A15").Select
Dim g As Variant
Dim find_rw As Variant
Dim r As Variant
Dim UERow As Range
Dim PIRow As Variant
PIRow = 0
Dim IDUform As Long
Dim PIform As Variant
Dim BoolRow As Boolean
BoolRow = False
Dim RangeData As Range
'Cette variable correspond à la ligne "Y2" du formulaire.
IDUform = Worksheets("Formulaire").Range("Y2").Value
With Worksheets("PI")
Set RangeData = Range("A8:B" & lstRw)
End With
'On met ensuite à jour l'information PI
For L = 16 To lstRwForm
PIform = Worksheets("Formulaire").Range("B" & lstRwForm).Value
With RangeData
Set UERow = .Find(IDUform, LookIn:=xlValues, lookat:=xlWhole)
find_rw = UERow.Row
Do While BoolRow = False
If Worksheets("PI").Range("B" & find_rw).Value = _
Worksheets("Formulaire").Range("A" & L).Value Then
BoolRow = True
Else
'On continue
Set UERow = .FindNext(UERow)
find_rw = UERow.Row
End If
Loop
End With
MsgBox Worksheets("PI").Range("B" & find_rw).Value
BoolRow = False
Next L
End Sub
--------------------
--
Werner
------------------------------------------------------------------------
Werner's Profile:
http://www.excelforum.com/member.php...o&userid=24304
View this thread:
http://www.excelforum.com/showthread...hreadid=386164