Consulting

Page 1 of 2 1 2 LastLast
Results 1 to 20 of 23

Thread: Solved: VBA Excel Question

  1. #1
    VBAX Regular
    Joined
    Feb 2009
    Posts
    31
    Location

    Solved: VBA Excel Question

    I am new to VBA. I have created userforms in excel. What I would like to do is have those forms appear only when clicked in a specific column. Also the form has checkboxes, and each cell will have different info. When the user returns to the specific cell ex:E5, I wan the form for that cell that they have checked boxes in to appear...Can anyone help me???

  2. #2
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    LLL,

    Welcome to the forum!

    I moved your question to a more appropriate area.

    Enjoy!

  3. #3
    VBAX Regular
    Joined
    Feb 2009
    Posts
    31
    Location
    Thanks for your help. Where will I access the thread?

  4. #4
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Welcome to VBAX
    Can you post a sample of your workbook? Use Manage Attachments in the Go Advanced reply section.
    Regards
    MD
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  5. #5
    VBAX Regular
    Joined
    Feb 2009
    Posts
    31
    Location
    For my initial question
    I would like for Column F only ,to go to UserForm1 , and Column G only, to UserForm2.


    A another item, I would like to do is this:
    For Column H, plan is to have a dropbox for the following:
    LLC/Partnership - (will go to UserForm3)
    Corp - (will go to UserForm4)
    Sole Prop - (will go to UserForm5)
    LLC - ( will go to UserForm6)

    Once a user has clicked on the form and checked boxes for a specified cell, that form only will appear upon reclicking in that cell


    My userforms will be made of checkboxes, so they may select multiple items

    Thanks for the help

  6. #6
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    I don't follow how your checkboxes relate to the spreadsheet
    Put this code in the Worksheet module. I've made it a double-click event, but this can be changed if required.
    [vba]
    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    Select Case Target.Column
    Case 6
    Cancel = True
    UserForm1.Show
    Case 7
    Cancel = True
    UserForm2.Show
    End Select
    End Sub

    [/vba]
    Last edited by mdmackillop; 02-16-2009 at 05:02 AM. Reason: Code correction
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  7. #7
    VBAX Regular
    Joined
    Feb 2009
    Posts
    31
    Location
    Okay, this works. On the userform there are checkboxes, if checks are placed in these boxes, upon return to that cell the form shows up with no checks? How do you get it to appear as last edited? Thanks so much for your help!

  8. #8
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Quote Originally Posted by LLL
    How do you get it to appear as last edited?
    Greetings LLL,

    Just as to that one question, if you are asking how MD got the code to be layed out so nicely - when posting a code snippet, use the little green/white VBA button right above the message window you are typing in. Then plant the code between the tags.

    Mark

  9. #9
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    This should show how to set checkboxes from sheet data and vice versa. It uses/sets dates in columns K-M

    If you find the code is acting strangely (taking you to the Double_Click code), it's because of a bug I can't figure out!
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  10. #10
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Hi Malcom,

    I think you meant to have an IF or something to test if we're in a column we care about, before cancelling the double-click.

    (Maybe? ...course I've been known to go down a wacky trail every now and then...)

    Mark

  11. #11
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Well caught. It should be moved within the Case statements.
    thanks
    Malcolm
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  12. #12
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    @mdmackillop:

    Shucks brother, it is usually you catching me. I am most happy to be able to return the favor on the the rare occasion.

    A great day to you and yours,

    Mark

  13. #13
    VBAX Regular
    Joined
    Feb 2009
    Posts
    31
    Location
    Hi you guys! Thanks for your help TO be sure I am following you correctly, what i need to do is have IF statements under the Cases for the worksheet code? Is this correct? I will attach my original sheet with the first code. If you can provide an example under just one checkbox, I would greatly appreciate it. I want to be able to check a box, relative to that cell. And be able to go back to that cell and see the boxes I have checked.

  14. #14
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Sorry, I just don't understand what you are trying to do with your checkboxes. Did you look at the attachment in Post #9?
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  15. #15
    VBAX Regular
    Joined
    Feb 2009
    Posts
    31
    Location
    Hi, yes I did and thanks for getting back to me. Upon clicking for example in column F userform1 appears. Each cell in column F, this applies to. But each cell will have different items checked in the userform at different times. I want the checkboxes to each cell in column F to save the individual data. Does that make sense? Thanks again for all your help

  16. #16
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    I want the checkboxes to each cell in column F to save the individual data
    I really have no idea what this means.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  17. #17
    VBAX Regular
    Joined
    Feb 2009
    Posts
    31
    Location
    Thanks for your patience, sorry. What I mean by that -I want the checkboxes to each cell in column F to save the individual data-

    I click on the cell and the userform appears -
    I click the checkboxes, so checkmarks appear -
    I leave that cell -
    Upon return to that cell, I would like to see what items I already checked off

    Does that help?

  18. #18
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    You need to store the information in the workbook, not in the Userform. This example writes an x into corresponding cells.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  19. #19
    VBAX Regular
    Joined
    Feb 2009
    Posts
    31
    Location
    Thank you so very much, got it!!

  20. #20
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Have a visit here, a lot of useful examples
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

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