+ Reply to Thread
Results 1 to 9 of 9

Have workbook open to default optionButton

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    03-05-2009
    Location
    usa
    MS-Off Ver
    Excel 2016 32Bit
    Posts
    1,173

    Have workbook open to default optionButton

    Looking for a way to have workbook open to optionbutton5 if the workbook name is Price Example ActiveXv2,if not then open workbook to how
    it was saved.?
    Thanks for suggestions Z
    Attached Files Attached Files
    Last edited by zplugger; 05-04-2015 at 09:21 AM.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,485

    Re: Have workbook open to default optionButton

        Dim wb As Workbook
        Set wb = ThisWorkbook
    
        If wb.Name = "Price Example using ActiveX v2.xlsm" Then
            Sheets("Products").OptionButton5 = True
        End If

  3. #3
    Forum Contributor
    Join Date
    03-05-2009
    Location
    usa
    MS-Off Ver
    Excel 2016 32Bit
    Posts
    1,173

    Re: Have workbook open to default optionButton

    Thanks davesexcel,almost there. It does set the option button right but sheet one is not update until you do sheet change. My default it will open to
    sheet1,so is it possible to have it set right on open. The Price Example using ActiveX v2.xlsm in upper post show better.

    Thanks

  4. #4
    Forum Contributor
    Join Date
    03-05-2009
    Location
    usa
    MS-Off Ver
    Excel 2016 32Bit
    Posts
    1,173

    Re: Have workbook open to default optionButton

    Maybe I'm going at this the wrong way, looking for any suggestions.

    Thanks Z

  5. #5
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,485

    Re: Have workbook open to default optionButton

    I don't know what your asking, put the code anywhere you want.

  6. #6
    Forum Contributor
    Join Date
    03-05-2009
    Location
    usa
    MS-Off Ver
    Excel 2016 32Bit
    Posts
    1,173

    Re: Have workbook open to default optionButton

    Thank You
    This part of the code works perfect,but it will not update sheet1 with correct data.On the sheet with optionbuttons there is a commandbutton to run this code to update sheet1.
     Dim wb As Workbook
        Set wb = ThisWorkbook
    
        If wb.Name = "Price Example using ActiveX v2.xlsm" Then
            Sheets("Products").OptionButton5 = True
        End If

    Here is update code,tried to add to workbook open with no luck.

    Private Sub cmdUpdate_Click()
        Dim cCont As Object
        
        For Each cCont In ActiveSheet.OLEObjects
            If cCont.Name Like "OptionButton?" Then
                If cCont.Object.Value = True Then
                                    
                    Sheets("Sheet1").lblName.Object.Caption = cCont.Object.Caption
                    Sheets("products").Range("i13") = cCont.Object.Caption
                    
                End If
                
            End If
        Next cCont
    End Sub
    need a way to click the button on open,not sure how to do this?.

    Thanks Z

  7. #7
    Forum Contributor
    Join Date
    03-05-2009
    Location
    usa
    MS-Off Ver
    Excel 2016 32Bit
    Posts
    1,173

    Re: Have workbook open to default optionButton

    added a welcome button on sheet 1 but it will not run the code from sheet1,runs from products sheet?

  8. #8
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,485

    Re: Have workbook open to default optionButton

    Try this,
    Private Sub Workbook_BeforeClose(Cancel As Boolean)
        Dim wb As Workbook
        Set wb = ThisWorkbook
    
        If wb.Name = "Price Example using ActiveX v2.xlsm" Then
            Sheets("Products").OptionButton5 = True
            Sheets("Sheet1").lblName.Object.Caption = Sheets("Products").OptionButton5.Caption
            Sheets("products").Range("i13") = Sheets("Products").OptionButton5.Caption
        End If
        wb.Save
    End Sub

  9. #9
    Forum Contributor
    Join Date
    03-05-2009
    Location
    usa
    MS-Off Ver
    Excel 2016 32Bit
    Posts
    1,173

    Re: Have workbook open to default optionButton

    Thanks davesexel works Perfect.
    Z

+ 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. Macro starting running on workbook open, not on option button selection
    By gjwilson1216 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-10-2014, 12:57 PM
  2. [SOLVED] Advise user if workbook open, who is the 'owner' and option to try again
    By TC1980 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-27-2013, 05:27 AM
  3. Macro in workbook app to change default (open command) directory.
    By Audiology in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-24-2012, 08:33 AM
  4. Always open workbook to default sheet and cell
    By penny in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-09-2007, 05:26 PM
  5. [SOLVED] Can I program Excel to open a workbook to a default worksheet?
    By Manzie in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-08-2005, 02:00 PM

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