Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 1676|回复: 4

[已解决]求助如何根据单选项按纽的医院名称写入到B1黄色单元格。谢谢

[复制链接]
发表于 2013-5-25 09:30 | 显示全部楼层 |阅读模式
求助如何在单项按纽选择后点击选择按纽提交到B1单元格
求助.rar (9.95 KB, 下载次数: 7)
发表于 2013-5-25 09:34 | 显示全部楼层
跟上一个方法差不多。
用SELECT CASE最好。
回复

使用道具 举报

发表于 2013-5-25 09:38 | 显示全部楼层    本楼为最佳答案   
  1. Private Sub CommandButton1_Click()

  2.         Dim objControl As Control
  3.         For Each objControl In Me.Controls
  4.             If TypeName(objControl) Like "OptionButton" Then
  5.                 If objControl.Value Then
  6.                     [b1].Value = objControl.Caption
  7.                     Exit Sub
  8.                 End If
  9.             End If
  10.         Next
  11.         MsgBox "没有选择项"
  12. End Sub
复制代码

评分

参与人数 1 +3 收起 理由
qinhuan66 + 3 很给力!谢谢老师

查看全部评分

回复

使用道具 举报

 楼主| 发表于 2013-5-25 09:39 | 显示全部楼层
hwc2ycy 发表于 2013-5-25 09:34
跟上一个方法差不多。
用SELECT CASE最好。

知识好深奥,一时难于理解。唉,读书不努力,现在努力学知识。
回复

使用道具 举报

发表于 2013-5-25 09:43 | 显示全部楼层
  1.     Dim str$
  2.     Select Case True
  3.         Case Me.OptionButton1.Value
  4.             str = Me.OptionButton1.Caption
  5.         Case Me.OptionButton2.Value
  6.             str = Me.OptionButton2.Caption
  7.         Case Me.OptionButton3.Value
  8.             str = Me.OptionButton3.Caption
  9.         Case Me.OptionButton4.Value
  10.             str = Me.OptionButton4.Caption
  11.         Case Me.OptionButton5.Value
  12.             str = Me.OptionButton5.Caption
  13.         Case Me.OptionButton6.Value
  14.             str = Me.OptionButton6.Caption
  15.     End Select
  16.     If Len(str) > 0 Then
  17.         [b1].Value = str
  18.     Else
  19.         MsgBox "请选择一项"
  20.     End If
复制代码
项数少时可以这样。

评分

参与人数 1 +3 收起 理由
qinhuan66 + 3 很给力!谢谢您老师

查看全部评分

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-4-20 23:35 , Processed in 1.812226 second(s), 14 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表