Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
vlookup VBA code | Excel Discussion (Misc queries) | |||
VLOOKUP as a vb code | Excel Discussion (Misc queries) | |||
Using VLOOKUP in VBA code | Excel Worksheet Functions | |||
VLOOKUP for Zip Code Ranges | Excel Worksheet Functions | |||
how to use a VLOOKUP function in a VBA code? | New Users to Excel |