I have two worksheets. Sheet1 contains data in B3:W296 and Sheet2 contains data in alternate columns B3:B23, D3:D23,..,T3:T23. Now I am supposed to fill up the empty alternate columns in Sheet2(C3:C23, E3:E23,..,U3:U23)
Sheet2 values are supposed to be filled like,
Sheet2.C3.value = VARP("Sheet1".Range(C3:C16)) ...
Sheet2.U3.value = VARP("Sheet1".Range(U3:U16))
For the row4 in Sheet2, the formula should be changed like,
Sheet2.C4.value = VARP("Sheet1".Range(C17:C30)) ...
Sheet2.U4.value = VARP("Sheet1".Range(U17:U30))
I have to do this in different files, so the number of rows and columns in both the sheets might vary. So I can't give the row and column numbers explicitly.
I have started writing the following code but I am stuck,
Dim lRow, lRow2 As Long
Dim lCol, lCol2 As Long
Dim i, j As Integer
lRow = ThisWorkbook.Worksheets("Sheet2").Cells.Find(What:="*", After:=Range("A1"), LookAt:=xlPart, _
LookIn:=xlFormulas, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, MatchCase:=False).Row
lCol = ThisWorkbook.Worksheets("Sheet2").Cells.Find(What:="*", After:=Range("A1"), LookAt:=xlPart, _
LookIn:=xlFormulas, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious, MatchCase:=False).Column
lRow2 = ThisWorkbook.Worksheets("Sheet1").Cells.Find(What:="*", After:=Range("A1"), LookAt:=xlPart, _
LookIn:=xlFormulas, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, MatchCase:=False).Row
lCol2 = ThisWorkbook.Worksheets("Sheet1").Cells.Find(What:="*", After:=Range("A1"), LookAt:=xlPart, _
LookIn:=xlFormulas, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious, MatchCase:=False).Column
For i = 3 To lRow
For j = 3 To lCol - 2 Step 2
ThisWorkbook.Worksheets("Sheet2").Range(j & i).Value = VarP(ThisWorkbook.Worksheets("Sheet1").Range())
Next j
Next i
I am not sure how to proceed with the for loop for this case.
Any help would be appreciated greatly. Thanks in advance.