+ Reply to Thread
Results 1 to 2 of 2

Userform TextBox.Value inside Formula, in VBA code

Hybrid View

schneij Userform TextBox.Value inside... 05-23-2013, 04:29 PM
schneij Re: Userform TextBox.Value... 05-23-2013, 06:03 PM
  1. #1
    Registered User
    Join Date
    03-05-2013
    Location
    My Desk
    MS-Off Ver
    Excel 2010
    Posts
    2

    Userform TextBox.Value inside Formula, in VBA code

    I cannot find anything on the net to help me and I've been searching ALL day. I'm trying to insert this FormulaArray into a cell via a userform and it contains a reference to a TextBox Value on that userform. For this example, I'm entering Driver, Joe into the TextBox

    .Range("B" & irow).FormulaArray = "=SUMPRODUCT(--('Period 1'!B13:B3000=" & addDriverName.Value & "),'Period 1'!C13:C3000)"
    It's taking the correct Value but it's not putting quotes around the TextBox Value.

    =SUMPRODUCT(--('Period 1'!B13:B3000=Driver, Joe),'Period 1'!C13:C3000)
    So, I figured I'd just add & """ before and after:

    .Range("B" & irow).FormulaArray = "=SUMPRODUCT(--('Period 1'!B12:B3000=" & """ & addDriverName.Value & """ & "),'Period 1'!C12:C300)"
    Thinking it would add the quotes... Now it comes back with

    =SUMPRODUCT(--('Period 1'!B13:B3000=" & addDriverName.Value & "),'Period 1'!C13:C3000)
    Can anyone help me please?

    Thank you very much, in advance.

    Jeff

  2. #2
    Registered User
    Join Date
    03-05-2013
    Location
    My Desk
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Userform TextBox.Value inside Formula, in VBA code

    I figured it out.

    .Range("B" & irow).FormulaArray = "=SUMPRODUCT(--('Period 1'!B13:B3000=" & Chr(34) & addDriverName.Value & Chr(34) & "),'Period 1'!C13:C3000)"

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1