Ulisses_Carso
New Member
- Joined
- Sep 4, 2020
- Messages
- 39
- Office Version
- 365
- Platform
- Windows
Is there a way to use a cell Value with Range.Offset Method?
I Have this code done by a colleague ( @JLGWhiz ) from the forum, in parts it works as i need, but i would like to use "fn.Offset(, "B2, B3, B4, etc...") and .Resize(, "D2, D3, D4, etc...")
This code will search in both columns A and bring me the entire line, i need only a few, and random, cells from each line.
I Have this code done by a colleague ( @JLGWhiz ) from the forum, in parts it works as i need, but i would like to use "fn.Offset(, "B2, B3, B4, etc...") and .Resize(, "D2, D3, D4, etc...")
This code will search in both columns A and bring me the entire line, i need only a few, and random, cells from each line.
VBA Code:
Dim sh1 As Worksheet, sh2 As Worksheet
Dim c As Range, fn As Range
Worksheets("Maintenance").Activate
Set sh1 = Sheets("BaseDin")
Set sh2 = Sheets("Maintenance")
With sh2
For Each c In .Range("A1", .Cells(Rows.Count, 1).End(xlUp))
Set fn = sh1.Range("A:A").Find(c.Value, , xlValues, xlWhole)
If Not fn Is Nothing Then
fn.Offset(, 1).Resize(, 31).Copy c.Offset(, 4)
End If
Next
End With