Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default Help with Vlookup code

I received the following a few months back and it works just fine, but I
need to amend what it does slighty:

Sub Insertdata()
With Worksheets("sheet1")
Set rng = .Range("C2:C" & .Range("C65536").End(xlUp).Row)
End With
With Worksheets("sheet2")
Set rng1 = .Range("A2:A" & .Range("A65536").End(xlUp).Row)
End With
For Each cell In rng
res = Empty
res = Application.VLookup(cell.Value, rng1.Resize(, 12), 2, 0)
If Not IsError(res) Then
cell.Offset(0, 5).Value = res
cell.Offset(0, 12).Value = Application.VLookup(cell.Value, rng1.Resize(,
12), 12, 0)
End If
Next cell
End Sub

At the moment it puts data from 2 columns on sheet2 onto sheet1, what I want
it to do now is put data from column P on sheet2 into column O on sheet1,
BUT ONLY IF THERE IS NOTHING IN THE CELL.

Thanks in advance.

Gareth


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
vlookup VBA code cluckers Excel Discussion (Misc queries) 16 August 19th 09 08:40 PM
VLOOKUP as a vb code Tdp Excel Discussion (Misc queries) 5 November 25th 08 10:01 PM
Using VLOOKUP in VBA code Mark Excel Worksheet Functions 2 August 18th 06 04:41 PM
VLOOKUP for Zip Code Ranges JerseyJR Excel Worksheet Functions 2 September 6th 05 06:37 PM
how to use a VLOOKUP function in a VBA code? Sunil New Users to Excel 3 June 13th 05 09:27 AM


All times are GMT +1. The time now is 09:30 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"