epactheactor
New Member
- Joined
- Sep 9, 2015
- Messages
- 38
Hello.
I know this has to be answered before but I couldn't find anything in the forums.
What I am trying to do is this...I have two named ranges, LR and LR2, each on a different sheet. I'm trying to create a If and For loop that would go through range LR and match it with a value in LR2 IF the value is close to it.
I tried to do Vlookup on this, but it kept giving me an error so I'm trying a different route. I know I could do a simple code like what is below if LR2 was a static number, but it's a range.
[/CODE]
Any help would be very grateful.
I know this has to be answered before but I couldn't find anything in the forums.
What I am trying to do is this...I have two named ranges, LR and LR2, each on a different sheet. I'm trying to create a If and For loop that would go through range LR and match it with a value in LR2 IF the value is close to it.
I tried to do Vlookup on this, but it kept giving me an error so I'm trying a different route. I know I could do a simple code like what is below if LR2 was a static number, but it's a range.
Code:
[CODE]
MX = Application.Max(LR)
For Each L In LR If Abs(LR2 - L) < MX Then
MX = Abs(LR2 - L)
oAd = LR2.Address
Range(L).Offset(0, lastcolumn + 2).Value = oAd
End If
Next L
Any help would be very grateful.