View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
joel[_405_] joel[_405_] is offline
external usenet poster
 
Posts: 1
Default Moving data from one sheet to a template, matching numbers


I modified the code to look for every occurance of the ID number in
column B on sheet 2

Sub MoveData()

With Sheets("Sheet1")
LastRow = .Range("A" & Rows.Count).End(xlUp).Row
RowCount = 1
Do While RowCount <= LastRow
ID = .Range("B" & RowCount)
If ID < "" Then
Num1 = .Range("D" & RowCount)
Num2 = .Range("E" & RowCount)

With Sheets("Sheet2")
Set c = .Columns("B").Find(what:=ID, _
LookIn:=xlValues, lookat:=xlWhole)
If c Is Nothing Then
MsgBox ("Cannot find ID : " & ID)
Else
FirstAddr = c.Address
Do
Range("D" & c.Row) = Num1
Range("A" & (c.Row + 1)) = Num2
Set c = .Columns("B").FindNext(after:=c)
Loop While Not c Is Nothing And c.Address < FirstAddr
End If

End With
End If
RowCount = RowCount + 1
Loop

End With

End Sub


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=165075

Microsoft Office Help