Results 1 to 10 of 10

Thread: VBA Assistance-UserForm

  1. #1

    VBA Assistance-UserForm



    Register for a FREE account, and/
    or Log in to avoid these ads!

    Iím using the following code in a User Form to copy values to set a cell range based on the location. I would like to adjust the code to copy the value to different cells based on the date listed in my date box and the location selected from my combo box.

    Ex: If the region Texas was chosen from my combo list and the date said 9/15/11 in the date box, it would copy the value from F120 to B131
    If the region Texas was chosen from my combo list and the date said 10/1/11 in the date box, it would copy the value from F120 to B132.
    This process would repeat all the way down to row B148. The dates used are the 1st and 15th of each month through May 2012.
    I would also need the code to follow the same example above for the other locations listed. The only difference is the cell range.
    Ex: Connecticut would be my next range and would need to copy from F121 to E131 thru E148.
    Once I have an understanding of how the code is written for two dates and their locations , I can go back and duplicate the code for the remaining locations.
    Code:
    Option Explicit
    Private Sub cmdCopyValue_Click()
       If cboLocation.ListIndex <> -1 Then
           Worksheets("Monthly Data").Range("F" & cboLocation.ListIndex + 120).Copy Worksheets("Monthly Data").Range("B" & cboLocation.ListIndex + 130)
           Worksheets("Monthly Data").Range("B" & cboLocation.ListIndex + 130).Value = Worksheets("Monthly Data").Range("B" & cboLocation.ListIndex + 130).Value
     
       End If
    End Sub
    Private Sub DTPicker1_Click()
       Me.TextBox1.Value = DTPicker1.Value
    End Sub
    Private Sub UserForm_Click()
    End Sub
    Private Sub UserForm_Initialize()
       cboLocation.List = Worksheets("Monthly Data").Range("A2:A8").Value
    End Sub
    Thanks
    Allen

  2. #2
    Administrator Ken Puls's Avatar
    Join Date
    Mar 2011
    Location
    Nanaimo, BC, Canada
    Posts
    2,195
    Articles
    57
    Blog Entries
    14
    Hi Allen, and welcome to the forum.

    Sorry for the late reply here, are you still in need of help? I'm not sure I totally follow the logic that you're after here... any way you could upload a sample workbook with some data to work with?
    Ken Puls, FCPA, FCMA, MS MVP (Excel)

    Master your data with Power Query: Purchase your copy of my book M is for Data Monkey today!

    Main Site: http://www.excelguru.ca -||- Blog: http://www.excelguru.ca/blog -||- Forums: http://www.excelguru.ca/forums
    Check out the Excelguru Facebook Fan Page -||- Follow Me on Twitter

    If you've been given VBA code (a macro) for your solution, but don't know where to put it, CLICK HERE.

  3. #3
    Ken,

    Thank you for responding. Yes, I am still in need of assistance. I will post a sample workbook sometime tomorrow.

    Regards,

    Allen

  4. #4
    Administrator Ken Puls's Avatar
    Join Date
    Mar 2011
    Location
    Nanaimo, BC, Canada
    Posts
    2,195
    Articles
    57
    Blog Entries
    14
    Sounds good.
    Ken Puls, FCPA, FCMA, MS MVP (Excel)

    Master your data with Power Query: Purchase your copy of my book M is for Data Monkey today!

    Main Site: http://www.excelguru.ca -||- Blog: http://www.excelguru.ca/blog -||- Forums: http://www.excelguru.ca/forums
    Check out the Excelguru Facebook Fan Page -||- Follow Me on Twitter

    If you've been given VBA code (a macro) for your solution, but don't know where to put it, CLICK HERE.

  5. #5
    Ken,

    I have some things going on the next few days and will not be able to post anything until Monday. Sorry for the delay.

    Thank you

    Allen

  6. #6
    Administrator Ken Puls's Avatar
    Join Date
    Mar 2011
    Location
    Nanaimo, BC, Canada
    Posts
    2,195
    Articles
    57
    Blog Entries
    14
    Not a problem!
    Ken Puls, FCPA, FCMA, MS MVP (Excel)

    Master your data with Power Query: Purchase your copy of my book M is for Data Monkey today!

    Main Site: http://www.excelguru.ca -||- Blog: http://www.excelguru.ca/blog -||- Forums: http://www.excelguru.ca/forums
    Check out the Excelguru Facebook Fan Page -||- Follow Me on Twitter

    If you've been given VBA code (a macro) for your solution, but don't know where to put it, CLICK HERE.

  7. #7
    Ken,

    I attached a word document and two excel files to this post. Please let me know if you have any questions.

    Thank you

    Allen
    Attached Files Attached Files

  8. #8
    Administrator Ken Puls's Avatar
    Join Date
    Mar 2011
    Location
    Nanaimo, BC, Canada
    Posts
    2,195
    Articles
    57
    Blog Entries
    14
    [quote=randonneur]
    Is there an alternative to using the Microsoft Date andTime Picker to show the calendar. For some reason, I receive an error messageon one of my machines that running Excel 2010, stating it cannot load theobject. I searched Google and they state this has to do with an ocx file thatis not registering.
    [quote]

    There's a few... you could roll your own, import someone else's, or just avoid it all together.

    I just used your code and built off that, didn't try to clean it up or improve it, but I think you'll find this works for your purposes. I just used text to hold the dates and convert it back into date format as necessary.

    This code could use some serious cleanup. I just wanted to knock it out quick for you tonight.
    Attached Files Attached Files
    Ken Puls, FCPA, FCMA, MS MVP (Excel)

    Master your data with Power Query: Purchase your copy of my book M is for Data Monkey today!

    Main Site: http://www.excelguru.ca -||- Blog: http://www.excelguru.ca/blog -||- Forums: http://www.excelguru.ca/forums
    Check out the Excelguru Facebook Fan Page -||- Follow Me on Twitter

    If you've been given VBA code (a macro) for your solution, but don't know where to put it, CLICK HERE.

  9. #9
    Thanks Ken. I will test it out and work on cleaning up the code.

    Allen

  10. #10
    Administrator Ken Puls's Avatar
    Join Date
    Mar 2011
    Location
    Nanaimo, BC, Canada
    Posts
    2,195
    Articles
    57
    Blog Entries
    14
    No worries. If you need help with that, let us know.
    Ken Puls, FCPA, FCMA, MS MVP (Excel)

    Master your data with Power Query: Purchase your copy of my book M is for Data Monkey today!

    Main Site: http://www.excelguru.ca -||- Blog: http://www.excelguru.ca/blog -||- Forums: http://www.excelguru.ca/forums
    Check out the Excelguru Facebook Fan Page -||- Follow Me on Twitter

    If you've been given VBA code (a macro) for your solution, but don't know where to put it, CLICK HERE.

Posting Permissions

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