dsmessenger
New Member
- Joined
- Jul 2, 2013
- Messages
- 5
Hello all,
I'm hoping one of you would be kind enough to help me with some code. I'm trying to adapt some code given to me previously to match my needs
Based on the workbook i submitted the code is; Which works fine in test but not on my actual workbook.
basically i have data in my "request worksheet" in range A49:Y58
I want the code to match two bits of data first in A49:A58 second in G49:G58 - Column A49:A58 needs to lookup and match the value in the "summary worksheet" range A3:A250 and G49:G58 in row D3:Y3 also in the "summary worksheet".
if both the above match it will paste the value from the cell in column Y (the requested date) in the request sheet to the matching row and column in the summary
Sub Copy_Dates()
Dim rg As Range, R As Range, C As Range
Dim i As Long, j As Long
Dim lRow As Long, lCol As Long
Set rg = ThisWorkbook.Worksheets("Request").Cells(1, 1).CurrentRegion
Set R = ThisWorkbook.Worksheets("Summary").Cells(1, 1).CurrentRegion.Columns(1)
Set C = ThisWorkbook.Worksheets("Summary").Cells(1, 1).CurrentRegion.Rows(1)
For i = 2 To rg.Rows.Count
For j = 2 To rg.Columns.Count
If IsEmpty(rg(i, j)) = False Then
lRow = R.Find(rg(i, 1).Value).Row
lCol = C.Find(rg(1, j).Value).Column
ThisWorkbook.Worksheets("Summary").Cells(lRow, lCol).Value = rg(i, j).Value
End If
Next j
Next i
End Sub
below i started trying to specify the range but keep but it does not work and returns an error For i and For j - Clearly a complete novice and I'm sure it is something very simple.
Sub Calloff()
Dim rg As Range, R As Range, C As Range
Dim i As Long, j As Long
Dim lRow As Long, lCol As Long
Set rg = ThisWorkbook.Worksheets("Sheet3").Range("A49:K58")
Set R = ThisWorkbook.Worksheets("Sheet2").Range("D2:Y50")
Set C = ThisWorkbook.Worksheets("Sheet2").Range("A3:A250")
For i = 2 To rg.Rows.Count
For j = 2 To rg.Columns.Count
If IsEmpty(rg(i, j)) = False Then
lRow = R.Find(rg(i, 1).Value).Row
lCol = C.Find(rg(1, j).Value).Column
ThisWorkbook.Worksheets("Summary").Cells(lRow, lCol).Value = rg(i, j).Value
End If
Next j
Next i
End Sub
I'm hoping one of you would be kind enough to help me with some code. I'm trying to adapt some code given to me previously to match my needs
Based on the workbook i submitted the code is; Which works fine in test but not on my actual workbook.
basically i have data in my "request worksheet" in range A49:Y58
I want the code to match two bits of data first in A49:A58 second in G49:G58 - Column A49:A58 needs to lookup and match the value in the "summary worksheet" range A3:A250 and G49:G58 in row D3:Y3 also in the "summary worksheet".
if both the above match it will paste the value from the cell in column Y (the requested date) in the request sheet to the matching row and column in the summary
Sub Copy_Dates()
Dim rg As Range, R As Range, C As Range
Dim i As Long, j As Long
Dim lRow As Long, lCol As Long
Set rg = ThisWorkbook.Worksheets("Request").Cells(1, 1).CurrentRegion
Set R = ThisWorkbook.Worksheets("Summary").Cells(1, 1).CurrentRegion.Columns(1)
Set C = ThisWorkbook.Worksheets("Summary").Cells(1, 1).CurrentRegion.Rows(1)
For i = 2 To rg.Rows.Count
For j = 2 To rg.Columns.Count
If IsEmpty(rg(i, j)) = False Then
lRow = R.Find(rg(i, 1).Value).Row
lCol = C.Find(rg(1, j).Value).Column
ThisWorkbook.Worksheets("Summary").Cells(lRow, lCol).Value = rg(i, j).Value
End If
Next j
Next i
End Sub
below i started trying to specify the range but keep but it does not work and returns an error For i and For j - Clearly a complete novice and I'm sure it is something very simple.
Sub Calloff()
Dim rg As Range, R As Range, C As Range
Dim i As Long, j As Long
Dim lRow As Long, lCol As Long
Set rg = ThisWorkbook.Worksheets("Sheet3").Range("A49:K58")
Set R = ThisWorkbook.Worksheets("Sheet2").Range("D2:Y50")
Set C = ThisWorkbook.Worksheets("Sheet2").Range("A3:A250")
For i = 2 To rg.Rows.Count
For j = 2 To rg.Columns.Count
If IsEmpty(rg(i, j)) = False Then
lRow = R.Find(rg(i, 1).Value).Row
lCol = C.Find(rg(1, j).Value).Column
ThisWorkbook.Worksheets("Summary").Cells(lRow, lCol).Value = rg(i, j).Value
End If
Next j
Next i
End Sub