Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Help With a Looping Task

Am new on macros. I need assistance to successfully loop thru a task.
The task is as follows: I have two long tables on different sheets. I
need to lookup and pick up date from the second table. I attempted
solving it by bringing the tables into one sheet but isnt running
properly.

Dim z As Long
Dim i As Long
z = 2
i = 2
Do While Range("A" & z) < ""
If Range("A" & z).Value = Range("E" & i).Value Then
Range("C" & z).Value = Range("F" & i).Value
z = z + 1
i = 2
Else
i = i + 1
End If
Loop

================================================== ============
sheet1 sheet2

Names Date Names Date
===== ====

AAICDLTD AAICDLTD 11-Jan-01
ABALUF ABANITO 27-Jul-01
ABIMACJ ABALUF 28-Aug-02
ABIMACJ 19-Nov-01
ADESEUN
26-May-03
ABALUF 28-Aug-02

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default Help With a Looping Task

Use the Vlookup function to do the work
-------
Sub Button1_Click()
Dim rng As Range
Dim i As Integer

With Worksheets("Data")
Set rng = .Range("a3:b5") 'make as long as you need
End With

For i = 1 To 3 ' how ever many cells there are

With Worksheets("Results") 'assuming the data you want goes to column b and
the lookup value is in Column A'
..Cells(2 + i, 2) = Application.WorksheetFunction.VLookup(.Cells(2 + i, 1),
rng, 2, 1)
End With

Next i

End Sub




"sylink" wrote in message
oups.com...
Am new on macros. I need assistance to successfully loop thru a task.
The task is as follows: I have two long tables on different sheets. I
need to lookup and pick up date from the second table. I attempted
solving it by bringing the tables into one sheet but isnt running
properly.

Dim z As Long
Dim i As Long
z = 2
i = 2
Do While Range("A" & z) < ""
If Range("A" & z).Value = Range("E" & i).Value Then
Range("C" & z).Value = Range("F" & i).Value
z = z + 1
i = 2
Else
i = i + 1
End If
Loop

================================================== ============
sheet1 sheet2

Names Date Names Date
===== ====

AAICDLTD AAICDLTD 11-Jan-01
ABALUF ABANITO 27-Jul-01
ABIMACJ ABALUF 28-Aug-02
ABIMACJ 19-Nov-01
ADESEUN
26-May-03
ABALUF 28-Aug-02



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Help With a Looping Task

Thanks David. I'll give it a try as suggested.

sylink

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
First ever task LIGHT USER Excel Discussion (Misc queries) 4 March 23rd 06 09:25 PM
dialog box for active cell task to speed repeditive task Todd F.[_2_] Excel Programming 3 August 9th 05 02:30 PM
Task bar PghPatti Excel Discussion (Misc queries) 4 February 13th 05 02:05 AM
Little task Robert Couchman[_4_] Excel Programming 3 February 20th 04 03:18 PM
Task ID for App Quartz Excel Programming 0 December 29th 03 06:31 PM


All times are GMT +1. The time now is 05:55 AM.

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

About Us

"It's about Microsoft Excel"