continuation

S

skitek

this is code i have created

Sub Button2_Click()
Dim d As Range
Dim LookupRange As Range, cell As Range, Found As Boolean
Dim DestRange As Range
Dim prst As String


Set LookupSheet = Sheet1 ' arkusz ksiêgowania
Set DestSheet = Sheet1 ' arkusz ksiêgowania

Worksheets("sheet1").Range("f2").Select

For i = 2 To 10

n = ActiveCell.Value
Set LookupRange = Intersect(LookupSheet.Columns("n")
LookupSheet.UsedRange)
Found = False
If n <> "" Then
For Each cell In LookupRange
If cell.Value = n Then
Range("di").Value = cell.Address.Offset(0, 1).Value

Found = True
Exit For
End If
Next cell
End If

If Not Found Then
msg = "Rekord nie istnieje na liœcie " & LookupSheet.Name
"."
MsgBox msg, vbOKOnly, "AutoCopy"

End If
Next i
End Sub


but probably sth is wrong with this line:

Range("di").Value = cell.Address.Offset(0, 1).Value

where "di" is Column "d" and row i

I would like to insert value of cell standing next to matched cell i
column (lookup - n) into cell which is next to "active cell"


thanks once more


skite
 
J

JE McGimpsey

If I understand what you want correctly, use this instead:

Cells(i, "D").Value = cell.Address.Offset(0, 1).Value
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top