VBA to Copy data using Input box as Source and paste in Target Workbook & Auto Generate Insert Scripts in Notepad.

AmarJ26

New Member
Joined
Jun 8, 2022
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi All,
I am struggling to get VBA scripts for the following 4 requirement, your assistance would be greatly appreciated

I have 2 workbooks "Deal_Loader1" and "Promo_Loader", PFA.

i) Script to Enter Input box value as "Deal_Loader1" to auto copy all the Columns in to "Promo_Loader" Workbook under Deal Sheet Columns C:F
ii) Script to Enter Input box value as CRNumber (C12345) in Column B of "Promo_Loader" Deal Sheet same value should be populated until end of the row.
CRNumber will be different for the future entries so when I copy next time the additional entries will be from Deal_Loader2 and those entries should be auto copied same with Input Box value for Deal_Loader2 from last empty row in Columns C:F and For Column B it should be from B12 until end of the row.
iii) Script to auto populate Sql Sheet for the rest of the entries until end of the last row from Deal sheet(A11:E11) based on formulas that we have in column A2:E2 and also for the future entries from Deal_Loader2, entries can be more but I should be able to manage until end of the row every time.
iv) Finally script for Sql: Input Box value as CRNumber to select column D:E entries of all the rows and copy them in to a New OR Existing Notepad file.

Deal G Formula:
=VLOOKUP(D2;Ref_data!A:B;2;FALSE)
Sql A Column Formula: =Deal!A2 Formula is similar on B and C columns
Sql D Column Formula: ="Delete from x_deal where deal_id ='"&C2&"';"
Sql D Column Formula:
="Insert into X_DEAL (DEAL_ID,Offer,Start_date,End_date,Rate) Values ('"&C2&"','"&VLOOKUP(C2;Deal!C:D;2;FALSE)&"','"&VLOOKUP(C2;Deal!C:E;3;FALSE)&"','"&VLOOKUP(C2;Deal!C:F;4;FALSE)&"','"&VLOOKUP(C2;Deal!C:G;5;FALSE)&"');"
 

Attachments

  • Deal_Loader1-Deal.PNG
    Deal_Loader1-Deal.PNG
    39 KB · Views: 3
  • Promo_Sheet-Deal.PNG
    Promo_Sheet-Deal.PNG
    55.6 KB · Views: 4
  • Promo_Sheet-Ref_data.PNG
    Promo_Sheet-Ref_data.PNG
    38.4 KB · Views: 4
  • Promo_Sheet-Sql.PNG
    Promo_Sheet-Sql.PNG
    44.8 KB · Views: 6

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Forum statistics

Threads
1,214,823
Messages
6,121,780
Members
449,049
Latest member
greyangel23

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