looking up cell in vba to paste extra data in that row

B-Man

Board Regular
Joined
Dec 29, 2012
Messages
183
Office Version
  1. 2019
Platform
  1. Windows
I currently have some vba code that opens another workbook and sheet, finds the last row and pastes the data in the blank row below.

Excel Formula:
 With wsDest.Range("A" & wsDest.Rows.Count).End(xlUp).Offset(1, 0) ' Find Column A last row + 1 to paste data
                    
                .Value = wsSource.Range("C3").Value                       ' (A) Batch
                .Offset(0, 1).Value = wsSource.Range("C2").Value          ' (B) Date
                .Offset(0, 2).Value = wsSource.Range("C4").Value          ' (C) Input

Im trying to add some code in another macro to lookup the sheet/column wsDest.Range("A:A") and find the wsSource.Range("C3").Value (Batch Number) that was pasted earlier so I can paste more data in that row. but struggling trying to get vba to somehow match wsSource.Range("C3")with the value in wsDest.Range("A:A") and select it so I can reference it to offset that cell to paste more data.
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Maybe something like the code below

VBA Code:
Sub Findit()
    Dim FoundCell As Range
    
    Set FoundCell = wsDest.Range("A:A").Cells.Find(wsSource.Range("C3"), , xlValues, xlWhole, , xlNext)
    
    If Not FoundCell Is Nothing Then
        FoundCell.Offset(, 10).Value = "your value" 'change offset to suit and "your value" to your pasted data
    Else
        MsgBox "cell not found"
    End If
End Sub
 
Upvote 0
Solution
Champion. that works. Only spent 5 hours on that :rolleyes: will match it to suit my code now.
 
Upvote 0

Forum statistics

Threads
1,214,960
Messages
6,122,479
Members
449,088
Latest member
Melvetica

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top