Calculate and display result in userform label (15 USD)

  • 10% Paid to OzGrid?
    Yes

    I need a VBA code to display the results in a label for the selected row. The example book has only one row, however the code will be used in a workbook that has multiple rows There are calculations (with formulas) inserted in the sheet, however this is only to help understand how to produce the final result in the label. This will not be in part of the sheet.

  • I can look at this for you

    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.

  • I have a solution for you.


    I will PM you my PayPal details and post the file here upon payment.

    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.

  • Can you explain this line of code? I'm trying to integrate the code into my workbook. In the example WB, I place the data in the columns to match my main WB, however, there are multiple rows with data. Ii would want to calculate the data on the selected row. If the selected row in row 15, calculate the data in row 15 only.


    x = [t4].CurrentRegion.Rows(5)

  • CurrentRegion is a block of cells without empty rows or columns, Rows(5) is the 5th row of that block.


    So all the data in the 5th row of the current region starting in cell T4 gets loaded into array x

    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.

  • Change

    Code
    x = [t4].CurrentRegion.Rows(5)

    to

    Code
    x = [t4].CurrentRegion.Rows(Selection.Row - 3)

    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 are going to have to unprotect the sheet using ActiveSheet.Unprotect <password> at the start and ActiveSheet.Protect <password> at he end.


    I cannot say what to do about ScrollArea without seeing your actual sheet and code.

    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.

  • The code works perfectly with the sample file you posted.


    So, either that sample was not a true representation of your actual file, or your actual file has some other data that causes the code to produce the error.


    I cannot say which without seeing your actual file.

    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.

  • KjBox has provided the solution in his post #3


    All Buys & Sells are located in your Row 8


    If you are working with a totally different structure than the one you initially posted, you will obviously have to adapt the solution :)

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

Participate now!

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