Hitechtoys
New Member
- Joined
- May 31, 2017
- Messages
- 2
I have looked through dozens of threads and have attempted to implement several with varying results.
I am an intermediate Excel user but new to VBA. I'm looking for VBA code to accomplish
the following task since I can't do it with a formula.
I have two different workbooks. I have a button placed in the Source workbook. When clicked, I'd like the
button to look in the Destination workbook in Column A to Match value with a cell (H13) in the Source wb.
When it finds the matching number, populate the Destination wb row with the cells below from the Source wb.
The Source wb cell (H13) is looking for a Match in the Destination wb in Column A. Once it finds a Match,
then copy the cells below into the correct row in the Destination wb.
Source wb cells to copy to the Destination wb row in [column]: C15 [L], C17 [E], C19 [F],
H15 [D], H19 [G], G21 , K21 [C], B22 [H], C33 [M], K33 [J], B34 , B54 [K]
The Destination wb can have 400+ rows to search in column A to locate a match.
I think I got the farthest with this code but my cells aren't reporting correctly...
Is this possible? Maybe I'm asking too much? After a week of searching threads and trying various attempts I thought I'd post it here.
Thank you in advance for your help or any input you can give!!
I am an intermediate Excel user but new to VBA. I'm looking for VBA code to accomplish
the following task since I can't do it with a formula.
I have two different workbooks. I have a button placed in the Source workbook. When clicked, I'd like the
button to look in the Destination workbook in Column A to Match value with a cell (H13) in the Source wb.
When it finds the matching number, populate the Destination wb row with the cells below from the Source wb.
The Source wb cell (H13) is looking for a Match in the Destination wb in Column A. Once it finds a Match,
then copy the cells below into the correct row in the Destination wb.
Source wb cells to copy to the Destination wb row in [column]: C15 [L], C17 [E], C19 [F],
H15 [D], H19 [G], G21 , K21 [C], B22 [H], C33 [M], K33 [J], B34 , B54 [K]
The Destination wb can have 400+ rows to search in column A to locate a match.
I think I got the farthest with this code but my cells aren't reporting correctly...
Code:
Sub VBA_Read_External_Workbook()
Dim Target_Workbook As Workbook
Dim Source_Workbook As Workbook
Dim Target_Path As String
Dim Source_Data As String
Target_Path = "C:\Test\"
Set Target_Workbook = Workbooks.Open("C:\Test\BIM_Notice_Log2.xlsm")
Set Source_Workbook = ThisWorkbook
'Need to add a 'MATCH VALUE' here? Match value in column A then populate the Row
'This will only do one row at a time... do I need a .Range statement?
Target_Data = Target_Workbook.Sheets(1).Cells(34, 2)(33, 3)(33, 11)(54, 2)
Source_Workbook.Sheets(1).Cells(1, 9)(1, 13)(1, 10)(1, 11) = Target_Data
'Update Target File
Source_Data = Source_Workbook.Sheets(1).Cells(1, 9)(1, 13)(1, 10)(1, 11)
Target_Workbook.Sheets(1).Cells(34, 2)(33, 3)(33, 11)(54, 2) = Source_Data
'Close Target Workbook
Source_Workbook.Save
Target_Workbook.Save
Target_Workbook.Close False
'Process Complete
MsgBox "Update Completed"
End Sub
Is this possible? Maybe I'm asking too much? After a week of searching threads and trying various attempts I thought I'd post it here.
Thank you in advance for your help or any input you can give!!