Consulting

Results 1 to 4 of 4

Thread: Solved: writing option button caption in a cell

  1. #1

    Solved: writing option button caption in a cell

    Hi guys

    I wanna loop through all my optionbuttons to find which one is set to true and then write it's Caption in a cell. The line " ActiveCell.text = optbut.Caption" is wrong but i don't know why. Any ideas ?

    [vba]Dim optbut As Object
    For Each optbut In Me.Controls

    If TypeName(optbut) = "OptionButton" Then
    If optbut.Object.GroupName = "centre" Then

    If optbut.Value = True Then

    ActiveCell.text = optbut.Caption

    End If

    End If

    End If

    Next optbut[/vba]

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Try
    [VBA]
    ActiveCell = optbut.Caption
    [/VBA]
    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'

  3. #3
    Still won't work

  4. #4
    Ok it works fine

    thanks MD

Posting Permissions

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