+ Reply to Thread
Results 1 to 9 of 9

VBA Command Button Macro

  1. #1
    Registered User
    Join Date
    12-13-2011
    Location
    ON
    MS-Off Ver
    Excel 2011
    Posts
    18

    VBA Command Button Macro

    Ok, this is an interesting one I think.

    I have a Worksheet, and a Macro which will load a User Form.

    the User Form as 2 Combo Boxes, One lists peoples name (Found on WorkSheet 2) and another will list a type of Gear (Found on Worksheet 3)

    I have a Button which needs to take the selected person from the first combo box, find there location on Worksheet 1 (Found somewhere in the A Column), and edit the corresponding cell in the D Column. I actually need it to take its current Value and Add a predetermines variable called TotCost

    So what I need help with, is the code to do the Search for, and edit Corresponding Cell in D
    Last edited by Thrawler; 01-17-2012 at 01:58 AM.

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: VBA Command Button Macro

    Hi

    To save us some time, can you attach an example file with your workbook, the form, and relevant buttons that reflects your real situation.

    rylo

  3. #3
    Registered User
    Join Date
    12-13-2011
    Location
    ON
    MS-Off Ver
    Excel 2011
    Posts
    18

    Re: VBA Command Button Macro

    Ok, so I haven't added the code to pull up the Userform, and ignore my horrible coding I'll make it look pretty once I get it all done..

    So basically, what I want it to do, is when the person "Add Loot Total to Spent Points" I want it to take the value of totcost and add it to the selected person Sent Points section. So if they purchased a gear for 1000 it would take the current 100 and add 1000.
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: VBA Command Button Macro

    Hi

    OK, here's one way.

    Please Login or Register  to view this content.
    this is the code for the command button Add Loot to Spent Points

    HTH

    rylo

  5. #5
    Registered User
    Join Date
    12-13-2011
    Location
    ON
    MS-Off Ver
    Excel 2011
    Posts
    18

    Re: VBA Command Button Macro

    What did you dim findpoints and findchar as?

    Dunno if this will do what I need it to do. I know my explanation was horrible and I apologize for that.

    I need the Button to find the name located in the first combo box on the Points Sheet, and take the corresponding value of that persons Spent Points, and Add the variable Totcost to it.

    That Make sense?


    So lets say, Altair is in the First Box, and the 2nd box says Head Piece, the value will show up under the button, that value should be added to Altair's Point Spent
    Last edited by Thrawler; 01-17-2012 at 12:47 AM.

  6. #6
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: VBA Command Button Macro

    Hi

    I got lazy and didn't do the dims. Make them both ranges.

    Did you actually run the code and see if it did anything?

    rylo

  7. #7
    Registered User
    Join Date
    12-13-2011
    Location
    ON
    MS-Off Ver
    Excel 2011
    Posts
    18

    Re: VBA Command Button Macro

    Just got it to work now, I had to fix the Run-time error.

    It does exactly what I needed it to do.

    Now to figure out why I have to be on the Costs Sheet in order to run the UserForm

  8. #8
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: VBA Command Button Macro

    Hi

    Easy way around that is to do something like

    Please Login or Register  to view this content.
    I think that will solve that loading problem.

    rylo

  9. #9
    Registered User
    Join Date
    12-13-2011
    Location
    ON
    MS-Off Ver
    Excel 2011
    Posts
    18

    Re: VBA Command Button Macro

    I got it, I added WS.Range to it, and it fixed it


    Thank you for all your help!

+ 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