Share via

Array formula for a textbox

Anonymous
2016-08-29T04:40:51+00:00

Hi,

I want textbox3 to return the value based on following array formula :

{=sum(vlookup(val(txtRegNum),newrange,{19,23},0))}

How to write vba code for this?

newrange = Sheet8!A1:BO10000000

Textbox1 is named as txtRegNum

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2016-08-29T06:50:36+00:00

Untested, but I think something like this should work...

textbox3 = Evaluate("SUM(VLOOKUP(" & Val(txtRegNum) & ",'" & newrange.Parent.Name & "'!" & newrange.Address & ",{19,23},0))")

Was this answer helpful?

0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Anonymous
    2016-08-29T07:08:44+00:00

    Wow! Its perfect sir. Many thanks.

    Request you to please explain what are the meaning of those modifications in the formula? And can it be done for SUMIFS too?

    I mean, if today is 29-Aug-2016, then it should add all the values below or equal to 29-Aug-2016. Table is as below :

    RegNum Date Amt. Date Amt. Date Amt.
    1 01-Jul-16 50 01-Aug-16 150 01-Sep-16 100
    2 02-Jul-16 20 02-Aug-16 100 02-Sep-16 50

    So, suppose if I search for RegNum1 today, it should return 200 e.g. (50+150).

    If I search for RegNum1 on 01-Sep-2016, it should then return 300 e.g. (50+150+100).

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2016-08-29T06:39:06+00:00

    Sir,

    It is vba variable name.

    Dim newrange As range

    Set newrange = Worksheet(Sheet8).Range("A:BO")

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2016-08-29T05:06:36+00:00

    Is newrange a VBA variable name or an Excel Defined Name?

    Was this answer helpful?

    0 comments No comments