Looking in 1 list and copying from another lfile

  • Thread starter Thread starter Gadarel
  • Start date Start date
G

Gadarel

Need help with a smal problem that i´ve ran into .
Im using this for a log report.
Kund = ActiveCell.Value
If Kund <> "" Then
Windows("Rtm.csv").Activate
Sheets("rtm").Select

Range("a2").Select

Cells.Find(What:=Kund, After:=ActiveCell, LookIn:=xlFormulas
LookAt _
:=xlPart, SearchOrder:=xlByColumns
SearchDirection:=xlNext, MatchCase:= _
False).Activate
ActiveCell.Offset(0, 5).Range("A1").Select
ErrorAction = ActiveCell.Value
Windows("totalkostnad mot intäkt.xls").Activate
ActiveCell.Offset(0, 7).Range("A1").Select
ActiveCell.Value = ErrorAction
ActiveCell.Offset(1, -7).Range("A1").Select
GoTo HittaKund
End If

And my problem is when there is a number in the first list that+s no
in the second one. Im getting an error mess.
Tried to use "On Error resume next" or "On Error goto 0" but non o
them worked as I wanted.
I need one that is going to the next line in the first list and will d
that until its getting to a empty cell
 
Dim rng as Range
Kund = ActiveCell.Value
If Kund <> "" Then
Windows("Rtm.csv").Activate
Sheets("rtm").Select

Range("a2").Select

set rng =Cells.Find(What:=Kund, After:=ActiveCell, LookIn:=xlFormulas,
LookAt _
:=xlPart, SearchOrder:=xlByColumns,
SearchDirection:=xlNext, MatchCase:= _
False)
if not rng is nothing then
rng.select
ActiveCell.Offset(0, 5).Range("A1").Select
ErrorAction = ActiveCell.Value
Windows("totalkostnad mot intäkt.xls").Activate
ActiveCell.Offset(0, 7).Range("A1").Select
ActiveCell.Value = ErrorAction
ActiveCell.Offset(1, -7).Range("A1").Select
End if
GoTo HittaKund
End If
 

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

Back
Top