+ Reply to Thread
Results 1 to 3 of 3

Form Default Value

  1. #1
    bw
    Guest

    Form Default Value

    The following is code for a UserForm. The Value of A1 in Sheet2 contains
    the value that I want to use as the default value for this form. The value
    of A1 is dynamic, and is the same as one of the values in the
    CombinedBankNames List.
    How do I do this please.

    Thanks,
    Bernie

    Private Sub CombinedBankNames_Change()
    boxvalue = CombinedBankNames.Value
    Call MoveBankData
    End Sub

    Private Sub UserForm_Initialize()
    Dim MyArray As Variant
    'Where mylist is the named range
    MyArray = Range("CombinedData")
    CombinedBankNames.List = MyArray
    End Sub



  2. #2
    Dave Peterson
    Guest

    Re: Form Default Value

    This seemed to work ok:

    Option Explicit
    Dim blkProc As Boolean
    Private Sub UserForm_Initialize()
    Dim res As Variant
    Dim MyArray As Variant
    'Where mylist is the named range
    MyArray = Range("CombinedData")
    CombinedBankNames.List = MyArray
    res = Application.Match( _
    ThisWorkbook.Worksheets("sheet2").Range("a1").Value, _
    Me.CombinedBankNames.List, 0)
    If IsError(res) Then
    'no match, design error??
    'do nothing
    Else
    blkProc = True
    Me.CombinedBankNames.ListIndex = res - 1
    blkProc = False
    End If
    End Sub

    Private Sub CombinedBankNames_Change()
    If blkProc = True Then Exit Sub
    MsgBox "hi"
    ' boxvalue = CombinedBankNames.Value
    ' Call MoveBankData
    End Sub

    The blkProc stuff stops the _change procedure from doing anything if we're just
    loading the combobox (it was a combobox, right?).



    bw wrote:
    >
    > The following is code for a UserForm. The Value of A1 in Sheet2 contains
    > the value that I want to use as the default value for this form. The value
    > of A1 is dynamic, and is the same as one of the values in the
    > CombinedBankNames List.
    > How do I do this please.
    >
    > Thanks,
    > Bernie
    >
    > Private Sub CombinedBankNames_Change()
    > boxvalue = CombinedBankNames.Value
    > Call MoveBankData
    > End Sub
    >
    > Private Sub UserForm_Initialize()
    > Dim MyArray As Variant
    > 'Where mylist is the named range
    > MyArray = Range("CombinedData")
    > CombinedBankNames.List = MyArray
    > End Sub


    --

    Dave Peterson

  3. #3
    bw
    Guest

    Re: Form Default Value

    Great Dave!
    This works just like I had envisioned.
    I appreciate your help.
    Bernie


    "Dave Peterson" <[email protected]> wrote in message
    news:[email protected]...
    > This seemed to work ok:
    >
    > Option Explicit
    > Dim blkProc As Boolean
    > Private Sub UserForm_Initialize()
    > Dim res As Variant
    > Dim MyArray As Variant
    > 'Where mylist is the named range
    > MyArray = Range("CombinedData")
    > CombinedBankNames.List = MyArray
    > res = Application.Match( _
    > ThisWorkbook.Worksheets("sheet2").Range("a1").Value,

    _
    > Me.CombinedBankNames.List, 0)
    > If IsError(res) Then
    > 'no match, design error??
    > 'do nothing
    > Else
    > blkProc = True
    > Me.CombinedBankNames.ListIndex = res - 1
    > blkProc = False
    > End If
    > End Sub
    >
    > Private Sub CombinedBankNames_Change()
    > If blkProc = True Then Exit Sub
    > MsgBox "hi"
    > ' boxvalue = CombinedBankNames.Value
    > ' Call MoveBankData
    > End Sub
    >
    > The blkProc stuff stops the _change procedure from doing anything if we're

    just
    > loading the combobox (it was a combobox, right?).
    >
    >
    >
    > bw wrote:
    > >
    > > The following is code for a UserForm. The Value of A1 in Sheet2

    contains
    > > the value that I want to use as the default value for this form. The

    value
    > > of A1 is dynamic, and is the same as one of the values in the
    > > CombinedBankNames List.
    > > How do I do this please.
    > >
    > > Thanks,
    > > Bernie
    > >
    > > Private Sub CombinedBankNames_Change()
    > > boxvalue = CombinedBankNames.Value
    > > Call MoveBankData
    > > End Sub
    > >
    > > Private Sub UserForm_Initialize()
    > > Dim MyArray As Variant
    > > 'Where mylist is the named range
    > > MyArray = Range("CombinedData")
    > > CombinedBankNames.List = MyArray
    > > End Sub

    >
    > --
    >
    > Dave Peterson




+ 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