I have attached the two files I will be working with, and have listed the code I am using below as reference (trying to adapt code) and I am surely lost as to what changes I need to make.
I need the information from columns B, AF, AN, AO, & AW from cal ref.xlsx to go to columns C, D, E,B, & F in payment macro.xlsm respectively.
Currently I have (with code below) where the information will pull when I enter in the POS REF into cell A4 and fill in the row's data. I need it to fill the information into the row where I enter the POS REF in column A.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCells As Range
Set KeyCells = Range("A4")
If Not Application.Intersect(KeyCells, Range(Target.Address)) _
Is Nothing Then
Application.Run "SHEET1.Get_POS_Data"
End If
End Sub
Sub Get_POs_Data()
Const srcWBName = "cal ref.xlsx"
Const srcWBFullPathAndName = "C:\Users\shelby\Documents\CAL REF.xlsx"
Const srcWSName = "Sheet1"
Const srcPOCol = "A"
Const destSheetName = "Sheet1"
Dim destWS As Worksheet
Const POEntryCell = "A4"
Dim myTargetCell As Range
Dim srcCol As Variant
Dim destCol As Variant
Dim LC As Integer
Dim srcWB As Workbook
Dim srcWS As Worksheet
Dim basicPath As String
Dim POToFind As String
Dim searchRange As Range
Dim foundPOEntry As Range
Set destWS = ThisWorkbook.Worksheets(destSheetName)
Set myTargetCell = destWS.Range(POEntryCell)
If IsEmpty(myTargetCell) Then
Exit Sub
End If
srcCol = Array("B", "AF", "AN", "AO", "AW")
destCol = Array("C", "D", "E", "B", "F")
On Error Resume Next
Set srcWB = Workbooks(srcWBName)
If Err <> 0 Then
Err.Clear
Set srcWB = Workbooks.Open(srcWBFullPathAndName)
End If
On Error GoTo 0
ThisWorkbook.Activate
Set srcWS = srcWB.Worksheets(srcWSName)
POToFind = UCase(Trim(myTargetCell.Text))
Set searchRange = srcWS.Range(srcPOCol & "1:" & _
srcWS.Range(srcPOCol & Rows.Count).End(xlUp).Address)
Set foundPOEntry = _
searchRange.Find(POToFind, searchRange.Cells(1, 1), xlValues, xlWhole, MatchCase:=False)
If foundPOEntry Is Nothing Then
MsgBox "PO # " & POToFind & " not found. Check your entry.", _
vbOKOnly + vbCritical, "No Match Found"
GoTo CleanupAndExit
End If
ActiveWorkbook.Save
End Sub
Bookmarks