-
option button的分组 在多个option button中如何只能选择一个 vba控件
2019-08-06 22:13:21如何给option button分组,使得用户在选择是或者否的时候,可以二选一或者三选一,而且各个选项之间互不干扰呢。方法非常简单,只要使用groupname设置一下分组就可以了。 这里设置一下分组后,同个分组的option ...如何给option button分组,使得用户在选择是或者否的时候,可以二选一或者三选一,而且各个选项之间互不干扰呢。方法非常简单,只要使用groupname设置一下分组就可以了。
这里设置一下分组后,同个分组的option button就只能选择一个了,非常方便。
GroupName可以是数字也可以是英文,大家可以酌情取名。
-
VBA_控件03
2020-06-06 23:52:51Sheet2.OptionButton1.Caption = "男" Sheet2.OptionButton2.Caption = "女" End Sub Sub attribute2() Sheet2.OptionButton1.Enabled = True Sheet2.OptionButton2.Enabled = True End Sub '组名 Sub attribute3() ...'单选按钮属性
Sub attribute1()
Sheet2.OptionButton1.Caption = "男"
Sheet2.OptionButton2.Caption = "女"
End Sub
Sub attribute2()
Sheet2.OptionButton1.Enabled = True
Sheet2.OptionButton2.Enabled = True
End Sub
'组名
Sub attribute3()
Sheet2.OptionButton1.GroupName = "性别"
Sheet2.OptionButton2.GroupName = "性别"
End Sub
'返回值
Sub attribute4()
Sheet2.Range("A1") = Sheet2.OptionButton1.Value
Sheet2.Range("b1") = Sheet2.OptionButton2.Value
End Sub
-
VBA生成KML文件
2019-07-19 16:17:27Private Sub OptionButton36_Click() Dim i As Integer Dim s As String '存储生成的代码 Dim f As String '保存的文件名 Dim rng As Range f = ThisWorkbook.Path & “\GZ.kml” '宏所在的文件内KML文件 ...SUB TEST() Dim i As Integer Dim s As String '存储生成的代码 Dim f As String '保存的文件名 Dim rng As Range f = ThisWorkbook.Path & "\GZ.kml" s = "<kml xmlns=""http://earth.google.com/kml/2.0"">" & Chr(13) & _ "<Folder>" 'Set rng = Intersect(Selection, ActiveSheet.UsedRange) x = Application.CountA(Worksheets("结果").Range("A:A")) Set rng = Worksheets("结果").[A1].CurrentRegion If rng Is Nothing Then MsgBox "请选择合适的数据信息!": Exit Sub For i = 1 To x s = s & "<Placemark><description></description><name>" & rng(i, 1).Value & _ " </name><LookAt>" & _ "<longitude>" & rng(i, 2).Value & "</longitude>" & _ "<latitude>" & rng(i, 3).Value & "</latitude>" & _ "<range>2000</range>" & _ "<tilt>0</tilt>" & _ "<heading>3</heading>" & _ "</LookAt><Point>" & _ "<coordinates>" & rng(i, 2).Value & "," & rng(i, 3) & ",0</coordinates>" & _ "</Point> </Placemark>" & Chr(13) Next s = s & Chr(13) & "</Folder></kml>" SaveFile s, f ' 件,则中文名可以正常显示 FileZM f, "GB2312", f, "UTF-8" '转换成UTF-8编码的文件 MsgBox "已生成!" END SUB
-
VBA运行时窗体动态创建控件.xlsm
2020-09-06 03:25:12在VBA编写的程序中,如果可以在运行时动态创建控件无疑是非常有用的,因为有些控件是...Forms.Optionbutton.1(选项按钮) Forms.Textbox.1(文本框) Forms.Listbox.1(列表框) Forms.Commandbutton.1(命令按钮) -
【VBA】【一天的心血,收藏一下】一键生成报表2
2018-10-31 14:10:15Public batch$ Sub crAddReport() '获取窗体单选框选择 ... If UserForm1.OptionButton1.Value = True Then batch = "一" ElseIf UserForm1.OptionButton2.Value = True Then bat...Public batch$ Sub crAddReport() '获取窗体单选框选择 UserForm1.Show If UserForm1.OptionButton1.Value = True Then batch = "一" ElseIf UserForm1.OptionButton2.Value = True Then batch = "二" ElseIf UserForm1.OptionButton3.Value = True Then batch = "三" End If t1 = Timer Application.ScreenUpdating = False Call importLog '引用模块2的方法 Call findBrokenStation '引用模块2的方法 Call nowCrReport2 Call crFile2 Application.ScreenUpdating = True t2 = Timer MsgBox "己完成,运行时间 = " & (t2 - t1) * 1000 & " ms" End Sub Sub crFile2() Worksheets("结果统计-新增").Copy With ActiveSheet .Select .Columns("A:E").Delete .Shapes.Range(Array("Picture 1")).Delete [I1] = "执行结果" [I2] = "断X" [I3] = "配齐4个XX" [I4] = "无XX数据" [I5] = "因XXXX未配齐" [I6] = "总计" [J1] = "数量" [J2].formula = "=COUNTIF(E:E,I2)" [J3].formula = "=COUNTIF(E:E,I3)" [J4].formula = "=COUNTIF(E:E,I4)" [J5].formula = "=COUNTIF(E:E,I5)" [J6].formula = "=SUM(J2:J5)" End With '格式化 Call formatting2 '选择批次 ActiveWorkbook.SaveAs "XXX测量配置结果_" & Month(Date) & "月第" & batch & "组.xlsx" End Sub Sub nowCrReport2() Application.ScreenUpdating = False Dim d As Object, rng As Range Set dCity = CreateObject("Scripting.Dictionary") Set dOSS = CreateObject("Scripting.Dictionary") With Worksheets("ip对应地市名工具") For i = 1 To .[A65536].End(xlUp).Row dCity.add .Cells(i, 1).Value, .Cells(i, 2).Value dOSS.add .Cells(i, 1).Value, .Cells(i, 3).Value Next End With Dim lRow%, leftIp$, cellsNum, freqNum% lRow = [A65536].End(xlUp).Row On Error Resume Next For i = 2 To lRow '如果Cells(i, 1).Value为空,则对应行不作处理,也为空 If Cells(i, 1).Value <> "" Then leftIp = Left(Cells(i, 1).Value, 6) Cells(i, 6) = dCity(leftIp) Cells(i, 7) = Cells(i, 2) '名称 Cells(i, 8) = Cells(i, 1) 'IP Cells(i, 9) = dOSS(leftIp) cellsNum = Cells(i, 4).Value freqNum = Cells(i, 5).Value Cells(i, 10) = addResult(cellsNum, freqNum) Cells(i, 11) = Cells(i, 4).Value Cells(i, 12) = Cells(i, 5).Value End If Next '此处妙,多重功能:删除A列空行,不正确IP,8.137站点 Columns("F:F").SpecialCells(xlCellTypeBlanks).EntireRow.Delete Application.ScreenUpdating = True End Sub Function addResult(cellsNum, freqNum) If cellsNum = "" Then addResult = "断X" ElseIf cellsNum = 0 Then addResult = "无XX数据" ElseIf freqNum / cellsNum = 4 Then addResult = "配齐4个XX" Else addResult = "因占用XX未配齐" End If End Function Sub formatting2() ' 置中,加边框,上色 Range("I1:J6").Select With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlCenter .WrapText = False .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .ReadingOrder = xlContext .MergeCells = False End With Selection.Borders(xlDiagonalDown).LineStyle = xlNone Selection.Borders(xlDiagonalUp).LineStyle = xlNone With Selection.Borders(xlEdgeLeft) .LineStyle = xlContinuous .ColorIndex = 0 .TintAndShade = 0 .Weight = xlThin End With With Selection.Borders(xlEdgeTop) .LineStyle = xlContinuous .ColorIndex = 0 .TintAndShade = 0 .Weight = xlThin End With With Selection.Borders(xlEdgeBottom) .LineStyle = xlContinuous .ColorIndex = 0 .TintAndShade = 0 .Weight = xlThin End With With Selection.Borders(xlEdgeRight) .LineStyle = xlContinuous .ColorIndex = 0 .TintAndShade = 0 .Weight = xlThin End With With Selection.Borders(xlInsideVertical) .LineStyle = xlContinuous .ColorIndex = 0 .TintAndShade = 0 .Weight = xlThin End With With Selection.Borders(xlInsideHorizontal) .LineStyle = xlContinuous .ColorIndex = 0 .TintAndShade = 0 .Weight = xlThin End With Range("I1:J1").Select With Selection.Interior .Pattern = xlSolid .PatternColorIndex = xlAutomatic .Color = 5287936 .TintAndShade = 0 .PatternTintAndShade = 0 End With Range("I6:J6").Select With Selection.Interior .Pattern = xlSolid .PatternColorIndex = xlAutomatic .ThemeColor = xlThemeColorAccent5 .TintAndShade = 0.599993896298105 .PatternTintAndShade = 0 End With Rows("2:6").Select Selection.RowHeight = 21 Columns("I:J").Select Selection.ColumnWidth = 17.88 End Sub
-
Excel VBA高效办公应用-第九章-VBA文秘办公技巧-Part1 (每日行程安排提醒)
2017-06-18 23:18:08首先,这是个很有趣的例子,可以考虑在日常工作中提醒个人事项。 代码如下: Option Explicit Private Sub CommandButton1_Click() Dim mop As Boolean '定义...Case OptionButton1 = mop '选中第一个,则 -
VBA制作DT(适用ERIC)
2019-07-24 09:15:49Private Sub OptionButton37_Click() 'DT制作 Shell "cmd.exe /c DEL " & ThisWorkbook.Path & "\*.mos" Application.Wait Now + TimeValue("00:00:01") Worksheets("脚本模板").Activate X = ... -
VBA-M crashing when adding cheats
2020-12-02 15:11:09<p>Clicking the add new cheats button crashes VBA-M <h3>Steps to reproduce the behavior <p>Open VBA-M, loading a game, click list cheats (assuming cheats was enabled), click the add new cheats button.... -
Not possible to set reference to xlwings in VBA Editor
2020-11-29 21:54:39<div><p>Hi, I downloaded Anaconda, and installed in the standard way.... button and nothing else, I am not sure if this is the supposed way)</p><p>该提问来源于开源项目:xlwings/xlwings</p></div> -
mfc e将控件置于窗口顶层_VBA学习手册(三)——控件窗体图形化设计
2020-12-03 15:41:19第十二部分 ActiveX控件一、ActiveX控件属性ActiveX控件英文名称中文名称特殊属性通用属性CommandButton命令按钮caption\enable\visibleleft\top微调按钮无caption属性Label文本框OptionButton单选按钮GroupName、... -
VBA批量读取TXT、CSV文件---字段提取异常处理方法(Schema.ini)
2019-07-24 09:20:46Private Sub OptionButton39_Click() '提取功能 Set rs = CreateObject("adodb.Recordset") cnn.Open "Provider = Microsoft.ace.Oledb.12.0;Extended Properties =TEXT;Data Source =" & ThisWorkbook.Path &... -
自动生成VBA窗体菜单
2010-08-16 15:23:46自动生成VBA窗体菜单 '*************************** '* 菜单类 * '*************************** Option Explicit Private WithEvents MenuBar_MenuItem As MSForms.Label '菜单项 Private WithEvents WorkForm As... -
Microsoft Office PPT 编程(VBA)学习 (不定时更新,正在学习 ing)
2015-07-27 10:10:57一、打开 控件工具箱 office 2003-2007:视图——》工具栏——》控件工具箱 office 2010:文件——》选项...Label、CheckBox、TextBox、CommandButton、OptionButton 详解:http://www.doc88.com/p-8989047352617.htm -
全民一起VBA提高篇 第二十六回 选项按钮轻松上手,附件控件琳琅满目
2019-05-31 12:06:22OptionButton:单选按钮Caption属性就是提示文字,Value属性True或False CheckBox:复选框Caption属性就是提示文字,Value属性True或False Frame:框架控件,带有“xyz”符号的控件 Image:图像控件,主要属性... -
Option to sort Code Explorer alphabetically
2020-12-30 03:15:58<div><p>It's handy being able to click ... button at the top of the <em>CE</em> pane with a drop down giving the various options.</p><p>该提问来源于开源项目:rubberduck-vba/Rubberduck</p></div> -
Programming Excel With Vba And .net.chm
2009-02-07 14:18:19Programming Excel with VBA and .NET Preface Part I: Learning VBA Chapter 1. Becoming an Excel Programmer Section 1.1. Why Program? Section 1.2. Record and Read Code Section 1.3. Change ... -
VBA的表单控件初接触(2):ActiveX控件的基础功能和基础代码
2020-03-02 10:23:13第1类:button ,option ,checkbox ,togglebutton ,分组框 一组togglebutton中会始终有一个是按下去的状态 如果是一组commandbutton就全部都始终都是弹起的状态 1.1 togglebutton 切换按钮/ 互斥按钮 1.1.1基本... -
excel2016 64bit的vba中使用API函数RegisterClass注册窗体类就Excel就崩溃
2019-12-01 21:51:56Option Explicit Public Declare PtrSafe Function RegisterClass Lib "user32" Alias "RegisterClassA" (Class As WNDCLASS) As Long Public Declare PtrSafe Function UnregisterClass Lib "user32" Alias ... -
Remove TODO items from TODO Explorer toolbar
2020-12-30 03:17:10We should have an option to remove the TODO comment from within the TODO Explorer - let's add a button to the window's toolbar to do that.</p><p>该提问来源于开源项目:rubberduck-vba/... -
Source Control Issue - crash on init, selecting working directory or cloning
2021-01-03 13:12:47Source Control option" 9. Select the "Settings" tab, and set the settings for User Name, Email Address, Default Repository Location. Click Update. 10. Click the unlabelled button, with the... -
No video for mono GB games (specific situation)
2020-12-09 04:38:042. Hit the Home button, then Game Settings, and then hit Video. Check that 'Colorize Mono GB' is set to Off; if it is, skip step 3. 3. Change that option from On to Off and then restart ... -
Refreshing Code Explorer deletes code in code pane
2020-12-30 03:40:21I clicked the refresh button in the CE - ALL of the code except the annotation and Option Explicit were deleted! I used Undo and the stubs returned. However, each time I refresh the CE the code stubs... -
Refactor|Remove Parameter can leave broken code
2020-12-30 05:46:29or just go with option <strong>C)</strong> as the most useful and longest lasting (option <strong>D)</strong> goes away with the click of a button and can be quickly forgotten) <p>Of course, if the ... -
Code inspection Fix dropdown needs redesign
2020-12-30 04:34:06Right now visually, it looks like a button that you push once to make the fix without being sure what the fix is going to be. <p>More optional: maybe include a number in the dropdown that indicates ... -
AMA Intake | Review: Handle scenario where claimant is different from Veteran
2020-12-31 22:08:52<div><p>The Form includes the option to list a claimant other than the Veteran. We need a way for users to view associated relationships from the corporate database, so they can select the relevant ... -
Multiplayer support
2020-12-31 04:12:35<div><p>(I'm moving this from the comments on #22) <p>Several GBA games support multiplayer, for example: * Kirby & the Amazing Mirror * The Legend of Zelda: ...RSDuck/vba-next-switch</p></div> -
Gamepad Keymappings cannot be set in the settings
2020-11-30 02:55:04If I enter the english version of that keys (Joy1-button1) it works until I change anything in the settings. <h3>Steps to reproduce the behavior <p>try to assign the keys. <h3>ROM details <p>Which ... -
thoughts from 1.0.9 to rev210
2020-12-08 23:06:17present in VBA-M r781, I am unsure if it is present in earlier releases of vbagx at the moment. f) In regards to the algorithm added to remove rubbish from rom titles... In my case there are is not a... -
Get control names of MS-Access forms & reports
2021-01-01 02:41:53VBA forms. <p>However the exported modules contain all the information we need - we "just" need to parse it, and pick up the value of the <code>Name</code> property whenever it's ... -
TeeChart Pro Activex Control v5
2018-05-10 16:05:14password access need the 'save password' option to be selected in the ADO dialogue. This is not a requirement when setting up an ADO connection via code. - Dragdrop events not functioning in .NET....
收藏数
35
精华内容
14