Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,564
- Office Version
- 365
- 2016
- Platform
- Windows
With reference to this code the code below.
It copies and pastes a range of cells to the cell defined by svcRow and svcCol. In our example, assume svcRow and svcCol = 3 and 10 respectively. (J3)
From there, I want to populate cell J7 with the value on that worksheet at cell M1. I am doing this with my failed use of offset. Using J3 as the base cell, I want to put the value of M1 at the same column (10) but at row 7. So, no offset of column, but an offset of 4 rows.
My cell (J7) isn't populating with the value of M1. Where have I gone wrong?
It copies and pastes a range of cells to the cell defined by svcRow and svcCol. In our example, assume svcRow and svcCol = 3 and 10 respectively. (J3)
From there, I want to populate cell J7 with the value on that worksheet at cell M1. I am doing this with my failed use of offset. Using J3 as the base cell, I want to put the value of M1 at the same column (10) but at row 7. So, no offset of column, but an offset of 4 rows.
My cell (J7) isn't populating with the value of M1. Where have I gone wrong?
Rich (BB code):
Dim LkFor As Variant
Dim dstart As Long, dend As Long
Dim ws As String
'Diamonds
With ws_front
.Unprotect
svcNum = 0
dstart = 0
dend = 0
LkFor = "D"
ws = "Master"
FirstAndLastRows ws, LkFor, dstart, dend
Stop
For i = dstart To dend
svcNum = svcNum + 1
.Range("G2") = svcNum
.Range("E2") = Right(ws_master.Cells(i, 1), 3)
svcRow = Application.WorksheetFunction.VLookup(svcNum, ws_lists.Range("A1:C51"), 2, False) '3
svcCol = Application.WorksheetFunction.VLookup(svcNum, ws_lists.Range("A1:C51"), 3, False) '10 (J)
rngTemp.Copy Destination:=.Cells(svcRow, svcCol)
.Cells(svcRow, svcCol).Offset(4, 0) = .Range("A1") 'destination M7? ... nothing
.Cells(svcRow, svcCol).Offset(4, 16) = ws_master.Cells(i, 6) 'destination Y7? ... nothing
.Cells(svcRow, svcCol).Offset(4, 22) = ws_master.Cells(i, 6) 'destination AE7? ... nothing
Next i
.Protect
End With
End Sub