zoukankan      html  css  js  c++  java
  • 批量插入选择框

    Sub fill_range_with_optionbuttons()
    'Erik Van Geit
    '050520 0138
    Dim rownr As Long, i As Integer
    Dim counter As Long
    Dim rng As Range
    Dim txt(2) As String
    Dim nm(2) As String
    
    'replace each occurence of 22 by 800
    Set rng = Range("A1:B22")
    txt(1) = "R"
    txt(2) = "V"
    nm(1) = "RRR"   'single R or V impossible "R1" is invalid name (= cellreference)
    nm(2) = "VVV"
    Application.ScreenUpdating = False
    
    Rows("1:22").RowHeight = 18
    
        For rownr = 1 To 22
        counter = 0
            For i = 1 To 2
            counter = counter + 1
              Set rng = Cells(rownr, i)
                  If i = 1 Then
                  ActiveSheet.GroupBoxes.Add(rng.Left, rng.Top, rng.Width * 2, rng.Height).Name = "box" & rownr
                  ActiveSheet.Shapes("box" & rownr).OLEFormat.Object.Characters.Text = ""
                  End If
              ActiveSheet.OptionButtons.Add(rng.Left, rng.Top, rng.Width, rng.Height).Name = nm(i) & rownr
                  With ActiveSheet.Shapes(nm(i) & rownr).OLEFormat.Object
                  .Characters.Text = txt(i)
                  .LinkedCell = Cells(rownr, 3).Address
                  End With
            Next i
        Next rownr
    
    Application.ScreenUpdating = False
    
    End Sub
  • 相关阅读:
    并发编程
    网络与WEB 编程
    包和模块
    元编程
    类和对象
    【算法题 14 LeetCode 147 链表的插入排序】
    剑指offer面试54题
    剑指offer 面试51题
    剑指offer 面试3题
    剑指offer 面试52题
  • 原文地址:https://www.cnblogs.com/kidoln/p/4514488.html
Copyright © 2011-2022 走看看