+ Reply to Thread
Results 1 to 1 of 1

VBA:comboboxes to present same date in different formats...ADAPT WITH CHANGE IN DATE

Hybrid View

AlexDobbin VBA:comboboxes to present... 04-13-2015, 08:30 PM
  1. #1
    Registered User
    Join Date
    04-13-2015
    Location
    New York, NY
    MS-Off Ver
    MS Office 2011 for Mac
    Posts
    4

    VBA:comboboxes to present same date in different formats...ADAPT WITH CHANGE IN DATE

    Hi all,

    I'm very new to VBA and excel development, so please take that into consideration as you read on.

    I'm trying to create a work form for a database that (should) collect various information in comboboxes, including the date, the weekday, and the month... Note: most of the time, the data will be inserted the day after it's been collected. So, I wanted to create one combobox for the date, one for the weekday, and one for the month, because I want columns for each of these in the database (If this is not necessary/efficient, please help! ) .

    Here's what I've got so far:

        
        'worksheet setup
        Dim ws As Worksheet
        Set ws = Worksheets("LookupList")
        
        'Date dropdown setup
        Dim cDateToday As Range
        
        For Each cDateToday In ws.Range("DateList")
            With Me.cboDate
                .AddItem cDateToday.Value
            End With
        Next cDateToday
        
        'If today is Monday, then set date to last friday, if any other weekday, set it to day before that
        If Weekday(Date - 1) <> 2 Then
            Me.cboDate.Value = Format(DateAdd("D", -Weekday(Date) - 1, Date), "Medium Date")
        Else
            Me.cboDate.Value = Format(Date - 1, "Medium Date")
        End If
    Problem #1: Right now, I am getting the date values from the list DateList in the worksheet LookupList which is just a long list of dates I created...is there a better way of doing this?

    Problem #2: When the user form is run, the correct date and format shows up. However, if I change the date, the dropdown list in the combobox starts from the initial date in given list...is there anyway to bring the list closer to the current date? Think Calendar view

    Problem #3: I want the weekday and month values to be directly correlated to the date value discussed above, so hypothetically when the user form is run the correct date, weekday, and month all show up (based on the same date value), then if I change the date, the weekday and month automatically update. Is this possible, if so how?

    The reason I want this functionality is so that on a Monday, I can run the work form and it will automatically have Friday's date, weekday, month info as it opens. When I'm done with Friday, I can run it again, switch the date to the Saturday's date (weekday and month automatically update), then repeat for Sunday.

    I have tried running the same code for the weekday and month as I have for the date, and they work until the date is changed. Once the date is changed, I have to manually change the weekday, which leads to format change, and same for month, which all leads to

    Again, I am very new to vba and don't know much about it all and appreciate any/all help!

    Thanks in advance!

    /Alex
    Last edited by AlexDobbin; 04-13-2015 at 09:20 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Date Formats Change inexplicably
    By yankiwibill in forum Excel General
    Replies: 0
    Last Post: 11-26-2014, 09:57 AM
  2. Change date formats using a macro 01.23.11
    By SAP_hostage in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-31-2011, 04:17 PM
  3. How to change multiple date formats in same column
    By muchado in forum Excel General
    Replies: 6
    Last Post: 11-10-2010, 01:37 AM
  4. Formulas - count the amount of working weeks from a date until present date
    By Andrew_Franklin in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-09-2008, 09:23 AM
  5. [SOLVED] How to Change Date Formats
    By Jessica in forum Excel General
    Replies: 2
    Last Post: 11-01-2005, 04:09 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