Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Loop don't work

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default Loop don't work


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
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
Why does this loop only NEARLY work?! Andrew[_3_] Excel Programming 3 July 25th 07 07:57 PM
loop does not work correctly [email protected] Excel Programming 3 August 23rd 06 12:27 AM
For Each - loop doesn't work. Intellihome[_31_] Excel Programming 3 June 29th 05 11:10 PM
Would a loop work? sixfivebeastman[_7_] Excel Programming 1 August 31st 04 03:12 PM
Why doesn't my loop work? Insp Gadget Excel Programming 5 December 22nd 03 10:56 AM


All times are GMT +1. The time now is 03:18 AM.

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"