Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
I have this procedure but it does not work. This procedure does not take all the data. What I want to do? I want to take data from the sheet "Datas2" and insert in the sheet "Datas". I take a column 1 in each sheet. Must use "FOR i= / Next i" ? Thanks in advance for your help. -------------------------------------------------------------------------- Sub Searchdatas() Dim NNumber As String Dim Condition As Boolean Dim i, j As Integer Sheets("Datas").Select i = 1 Do NNumber = Cells(i, 1).Value j = 1 Condition = False Do If Nom = Sheets("Datas2").Cells(j, 1).Value Then Sheets("Datas").Cells(i, 3).Value = Sheets("Datas2").Cells(j, 3).Value Sheets("Datas").Cells(i, 4).Value = Sheets("Datas2").Cells(j, 4).Value Condition = True End If j = j + 1 Loop While (Cells(j - 1, 1).Value < "" And Condition = False) i = i + 1 Loop While Cells(i - 1, 1).Value < "" End Sub -------------------------------------------------------------------------- |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() In the code line: "If Nom = Sheets("Datas2").Cells(j, 1).Value Then", Nom has no value assigned to it so the comparison will always be False. -- Jim Cone Portland, Oregon USA http://www.contextures.com/excel-sort-addin.html .. .. .. "If" wrote in message ... Hello, I have this procedure but it does not work. This procedure does not take all the data. What I want to do? I want to take data from the sheet "Datas2" and insert in the sheet "Datas". I take a column 1 in each sheet. Must use "FOR i= / Next i" ? Thanks in advance for your help. ---------------------------------------- Sub Searchdatas() Dim NNumber As String Dim Condition As Boolean Dim i, j As Integer Sheets("Datas").Select i = 1 Do NNumber = Cells(i, 1).Value j = 1 Condition = False Do If Nom = Sheets("Datas2").Cells(j, 1).Value Then Sheets("Datas").Cells(i, 3).Value = Sheets("Datas2").Cells(j, 3).Value Sheets("Datas").Cells(i, 4).Value = Sheets("Datas2").Cells(j, 4).Value Condition = True End If j = j + 1 Loop While (Cells(j - 1, 1).Value < "" And Condition = False) i = i + 1 Loop While Cells(i - 1, 1).Value < "" End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Why does this loop only NEARLY work?! | Excel Programming | |||
loop does not work correctly | Excel Programming | |||
For Each - loop doesn't work. | Excel Programming | |||
Would a loop work? | Excel Programming | |||
Why doesn't my loop work? | Excel Programming |