VBA to find column header through Msg Box

  • Hi,


    I'm looking for a VBA code to locate column header and fill the values till last available row.


    Attached sample sheet for reference.


    In the attached sheet,


    1) Locate column header using msg box1 from the available sheets of workbook (Eg, Find "Truck1")

    2) Enter value(msgbox 2) - 1250

    3) Enter currency(msgbox 3) - AED

    4) Value and currency should be updated till last available row.


    Please share your suggestions.


    Found the below code in forum but not sure what to update. Please help

  • Try this.



    Your entry into the Input Box should be something like:


    Truck4, 234.87, USD


    Note you had "Truck1" in both cells A1 & A2, headers must be unique, I changed A1 to "Index"

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • Sorry my mistake. Try this

    The entry into the input Box should now be like: Header4, Truck4, 345.56, USD


    I have indicated in the code where you will need to change it for the actual Name of your Output workbook (which needs to be open when the code is run from the Active workbook).

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • Is that in the sample workbook or your actual workbook?


    What did you enter in the Input Box?

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • You forgot to enter the Header for Sheet 2, your entry should be


    Header7, Truck7, 134, CAD

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • Sorry KjBox, Macro works. But


    My requirement is


    Eg 1

    "Truck7, 134, CAD"


    Output:

    Truck7Truck7C
    134CAD


    The above value should be dragged down till the last available row.


    Eg2


    "Header6, 256, AED"


    Output:

    Header6Header6C
    256AED


    Header and truck won't be same value. Hence it shouldn't be merged.


    My workbook has 6 sheets with unique headers till (A1:KW1). So the macro will perform the search in all the sheets and find the header and the value with currency will be entered in whole column.


    Sorry again.. I should have explained it clearly.

  • Ok it is clearer now.


    I think the best method would be to have an Input area on the Active workbook where you would enter all 6 Headers, Amounts and Currencies, then click a button to run the macro and update the Output Workbook


    I will knock up an example and post it here (or you could attach your workbook which would be the Active workbook)

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • You said earlier that the code would be run from another (Active) workbook, do you now want an Input sheet in the same workbook as the Output Sheets instead?

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • Quote

    I think the best method would be to have an Input area on the Active workbook where you would enter all 6 Headers, Amounts and Currencies, then click a button to run the macro and update the Output Workbook

    I thought you asked me to add input sheet. I don't require it. Msgbox works fine.


    Your previous macro works but


    I don't require this combo. - Header7, Truck7, 134, CAD


    Required combination -

    Example 1 - Truck7, 134, CAD

    Example 2 - Header7, 154, USD

    Example 3- Ducatti1, 156,AED


    Macro will be running through personal macro workbook.

  • Sorry, I thought you wanted all the sheets updating at the same time (but with different data).


    Try this


    Change the workbook name as required. The 1st entry in the Input Box is now the Name of the sheet that needs updating, for example:


    Sheet1, Truck4, 2345.67, AED

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • You're welcome.

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!