Results 1 to 3 of 3

VBA UserForm - Contact sheet; Using a ComboBox array to write data to specific column

Threaded View

willmason VBA UserForm - Contact sheet;... 07-01-2014, 07:38 AM
laxmanann Re: VBA UserForm - Contact... 07-01-2014, 08:44 AM
willmason Re: VBA UserForm - Contact... 07-01-2014, 09:44 AM
  1. #1
    Registered User
    Join Date
    07-01-2014
    Location
    Nottingham
    MS-Off Ver
    2013
    Posts
    3

    VBA UserForm - Contact sheet; Using a ComboBox array to write data to specific column

    Hi all,

    Apologies if this is not as informative as it should be; I'm relatively new to VBA.

    I've been writing a UserForm in Excel that serves the purpose of a front-end contact/reporting spreadsheet.

    I've managed to get a multitude of elements to work together as of yet, however have been having problems writing data to the correct place on the spreadsheet.

    What I've already achieved:

    The first interactive portion of the userform currently has a TextBox (ArtistAgentAddEmail) - this is the email that we would like inputting on the spreadsheet.

    a ComboBox which is populated on 'Userform_Initialize' into an array (ArtistAgentAddDestination) - The range of this array is A1:AC1.
    Public Sub UserForm_Initialize()
    
    ArtistAgentAddEmail.SetFocus
    
        Dim MultiColumnArray As Range
        Dim Element As Range
        
        Set MultiColumnArray = Worksheets(1).Range("a1:ac1")
        
        For Each Element In MultiColumnArray
            Me.ArtistAgentAddDestination.AddItem Element.Value
        Next Element
    End Sub
    What I would like to do next:

    The issue that I've been having is getting the email to be written into the correct column. Once I have typed in my email and chosen my destination from the combobox, I would like to write this email address in the column of the destination chosen.

    E.G. The first 5 elements of my ComboBox array are: Neil O'Brien, CAA, CODA, ITB and PRIMARY. If i got an email from somebody in the CAA organisation to add a new contact to the reporting, I would like to be able to add this address via the userform underneath the previously added contact.

    The code that I am currently using for my confirm button is:

    Private Sub ArtistAgentAddConfirm_Click()
    
    Dim MSG1 As Integer
    
    With CreateObject("VBScript.RegExp")
            .Pattern = "^[\w-\.]+@([\w-]+\.)+[A-Za-z]{2,3}$" 'This is to validate certain characters in an Email address
            If Not .test(ArtistAgentAddEmail.Value) Then
                MsgBox "Please include Email address; E.G. joe.bloggs@email.com"
                      Cancel = True
                    Else
                    MSG1 = MsgBox("Are you sure you would like to add " & ArtistAgentAddEmail.Value & " to the " & ArtistAgentAddDestination.Value & " column?", Buttons:=vbYesNo)
                        If MSG1 = vbYes Then
                            MsgBox ArtistAgentAddEmail.Value & " has been added to the spreadsheet!"
                            ArtistAgentAddEmail.Text = ""
                        
                            Else
                                MsgBox "You have cancelled the addition of " & ArtistAgentAddEmail.Value
                        End If
            End If
    End With
    
    End Sub
    I apologise if I've been too vague, and any assistance is appreciated.
    Attached Files Attached Files
    Last edited by willmason; 07-01-2014 at 09:53 AM. Reason: Added my example workbook

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Enter data under specific Range (columns) via userform and combobox
    By kaurka in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-09-2014, 12:01 PM
  2. [SOLVED] Save and Send Userform data to a specific email address based on Combobox value
    By GAMU in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-30-2013, 01:13 PM
  3. write userform data to cell based on column header
    By EMAP in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-13-2012, 08:30 AM
  4. userform - lookup and write data to a specific row in a worksheet
    By EMAP in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-03-2012, 02:01 PM
  5. Read Data into an Array, Write Data into Another Sheet (Excel VBA Only) [v14/2010]
    By lloydgodin in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-15-2012, 07:22 PM

Tags for this Thread

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