View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Werner[_3_] Werner[_3_] is offline
external usenet poster
 
Posts: 1
Default Condition IF problem in Excel VBA


Forget about it, I've found my error. Here's the working code for
matching two data lists and matching the matching results with another
specified code number to have only the results matching this third
condition :

Sub Transfer_PI_Data()

' Local Variables
Dim rngUEData As Range, rngUE As Range, rngPIData
As Range, rngPI As Range

' Set UE data range
Set rngUEData =
Worksheets("UE").Range(Worksheets("UE").Range("CHA MP_DÉBUT_BD").Offset(1,
0), Worksheets("UE").Range("A65536").End(xlUp))

' Set PI data range
Set rngPIData =
Worksheets("PI").Range(Worksheets("PI").Range("CHA MP_DÉBUT_BD").Offset(1,
0), Worksheets("PI").Range("A65536").End(xlUp))

Dim IDUform As Long

IDUform = Worksheets("Formulaire").Range("AB2").Value

' Transfer PI data for each UE data entry
Application.Calculation = xlCalculationManual
For Each rngUE In rngUEData
For Each rngPI In rngPIData
If Trim(UCase(rngPI)) = Trim(UCase(rngUE)) Then
If rngPI = IDUform Then
If Worksheets("Formulaire").Range("A12") = "" Then

Worksheets("Formulaire").Range("A12").Range("A1:AD 1") =
rngPI.Range("A1:AD1").Value
Else

Worksheets("Formulaire").Range("B65536").End(xlUp) .Offset(1,
-1).Range("A1:AD1") = rngPI.Range("A1:AD1").Value
End If
End If
End If
Next rngPI
Next rngUE
Application.Calculation = xlCalculationAutomatic


End Sub

Bye!

Werner


--
Werner
------------------------------------------------------------------------
Werner's Profile: http://www.excelforum.com/member.php...o&userid=24304
View this thread: http://www.excelforum.com/showthread...hreadid=379431