Copy/Paste to Specific Row with matching Value

D

David

I have a macro that works when matching both row and column values to paste a
value in a cell.
Now, I need to paste about 10 values into the same columns, but into the row
that has the right value.
Example: I want to paste the same 10 values from one workbook into a row in
another workbook that has the exact same Franchise number in Column A as the
Franchise number from the first worksheet (the numbers are in Column A, begin
on row 3 and start with 1 and go down to 200. Rows 1 & 2 have titles).
The code I'm usings seems like it's working, but nothing is happening on my
test of the first datapoint. Can someone help?
Here's the code I'm using...

Sub January()

Dim iOffice As Integer, iValue

wbData.Activate 'Data comes from here

With wbData.Sheets("Global & Monthly Inputs")
iOffice = .Range("B6")
iValueFN = .Range("B5")
'End With

' apply iValueFN - Variance to matched row

wbTarget.Activate 'Data goes to here

With wbTarget.Sheets("Monthly Data")
Dim lastrow As Long, lastcol As Long, xV As Long, xR As Long, xC As Long
lastrow = .Cells(Rows.Count, 1).End(xlUp).Row
'get matching row
For xV = 1 To lastrow
If iOffice = .Cells(xV, 1) Then xR = xV
Next xV
If xR = 0 Then MsgBox "Office: " & iOffice & " not found in summary Table"

If xR > 0 Then .Cells(xR, 2) = iValueFN 'Column 2 (B) will always be
used for this value
End With
'Is not working to copy to specific row!!

End Sub


THanks!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top