LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Finding two variables on the same row to match function


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

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can the Match function handle more than 7 variables? Zakynthos Excel Worksheet Functions 3 August 9th 07 10:52 AM
Offset function with nested match function not finding host ss. MKunert Excel Worksheet Functions 1 March 21st 06 10:46 PM
Index Match function for multiple linked variables Bob Excel Worksheet Functions 13 November 23rd 05 12:56 AM
Index Match function for multiple linked variables Bob Excel Worksheet Functions 0 November 22nd 05 02:12 AM
finding variables in a column solo_razor[_31_] Excel Programming 1 November 12th 03 01:15 PM


All times are GMT +1. The time now is 02:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"