Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Need a vb loop for vlookup

I need a VB loop which will looks at ID's in cells A2 to A400, check to
see if corresponing ID's exist in cells I2:I400. If so, pick up Column
M and paste this back into Col G. If the ID does not exist then it
should say something like "New". I have got this far (gleamed and
amended from other Newsgroups postings) but I am unable to work out how
to do the loop.
Can somebody please help?

Many thanks
Tony

Sub CheckTotals()
With Worksheets("Totals")
.Cells(2, 7) = Application.VLookup(.Cells(2, 1), .Range("I2:M400"),
5, False)
End With
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 318
Default Need a vb loop for vlookup

You are nearly there.

Sub CheckTotals()
Dim i%
With Worksheets("Totals")
For i = 2 to 400
.Cells(i, 7) = Application.WorksheetFunction.VLookup(.Cells(i, 1),
..Range("I2:M400"),
5, False)
Next i
End With
End Sub

By the way you can do the same thing through a simple formula entered in
G2:G400

Alok


" wrote:

I need a VB loop which will looks at ID's in cells A2 to A400, check to
see if corresponing ID's exist in cells I2:I400. If so, pick up Column
M and paste this back into Col G. If the ID does not exist then it
should say something like "New". I have got this far (gleamed and
amended from other Newsgroups postings) but I am unable to work out how
to do the loop.
Can somebody please help?

Many thanks
Tony

Sub CheckTotals()
With Worksheets("Totals")
.Cells(2, 7) = Application.VLookup(.Cells(2, 1), .Range("I2:M400"),
5, False)
End With
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
using a vlookup command in a for next loop in a macro in excel Amethyst Excel Discussion (Misc queries) 3 March 17th 07 01:30 PM
VLOOKUP loop multiple times Lenny Excel Worksheet Functions 3 September 28th 05 10:31 AM
Advancing outer Loop Based on criteria of inner loop ExcelMonkey Excel Programming 1 August 15th 05 05:23 PM
Find & Replace / Loop & Vlookup thom hoyle Excel Programming 5 June 25th 05 12:56 AM
Problem adding charts using Do-Loop Until loop Chris Bromley[_2_] Excel Programming 2 May 23rd 05 01:31 PM


All times are GMT +1. The time now is 05:34 PM.

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"