ryantttheba
New Member
- Joined
- Mar 15, 2022
- Messages
- 1
- Office Version
- 365
- Platform
- Windows
I currently have two worksheets, a database sheet and a "dashboard" sheet that shows selected data given an empty value. I am trying to create VBA code so that when the macro is run, the macro will copy the date from the dashboard into the matching invoice field in the database sheet.
DashboardView
Database View
So basically - once the user runs the macro - "03/14/2022" will copy and pasted in the invoice number "2022-05-201" in the database.
I have the current code so far and would also like it to loop for all the rows .. can someone please help? Thanks in advance!
Sub Search ()
i=Sheets("DashboardView").Range("c3").Value
m= Application Match(i, Sheets("DatabaseView").Range("B:B"),0)
Sheets("DashboardView").Select
Range("B" & m).Select
Selection.Copy
Sheets("DatabaseView").Select
Range("B" & m).Select
ActiveSheet.Paste
Sheets("DashboardView").Select
Application.CutCopyMode=False
Selection.ClearContents
'Loop
Dim a as integer
for c = 3 to 10
cells (c,[column number]).value=c
next c
end sub
End Sub
DashboardView
Precondition | Invoice Number (Unique Identifier that has been filtered) | Invoice Confirmation Date |
"Invoice unpaid" | 2022-34-861 | To be paid |
2022-05-201 | [User Enters] 03/14/2022 |
Database View
Invoice Number | Invoice Confirmation Number | Other Data | Other Data | Other Data |
2022-34-861 | To be confirmed | ... | x | x |
2022-05-201 | To be confirmed | ... | x | x |
So basically - once the user runs the macro - "03/14/2022" will copy and pasted in the invoice number "2022-05-201" in the database.
I have the current code so far and would also like it to loop for all the rows .. can someone please help? Thanks in advance!
Sub Search ()
i=Sheets("DashboardView").Range("c3").Value
m= Application Match(i, Sheets("DatabaseView").Range("B:B"),0)
Sheets("DashboardView").Select
Range("B" & m).Select
Selection.Copy
Sheets("DatabaseView").Select
Range("B" & m).Select
ActiveSheet.Paste
Sheets("DashboardView").Select
Application.CutCopyMode=False
Selection.ClearContents
'Loop
Dim a as integer
for c = 3 to 10
cells (c,[column number]).value=c
next c
end sub
End Sub