zoukankan      html  css  js  c++  java
  • 【 学点VBA之EXCEL 】二

    (1)在VBA中创建一个窗体,初始化其位置,并调用之...

    Sub CallForm()
    UserForm1.Show
    '显示窗体
    UserForm1.Left = 600 '显示位置
    UserForm1.Top = 180
    End Sub


    Private Sub CommandButton1_Click()
    CallForm
    '调用
    End Sub

    (2)Excel的单元格的字体颜色、单元格的背景颜色


    代码
    Private Sub CommandButton1_Click()
    Dim i, j, k As Integer
    j
    = 0
    k
    = 0
    l
    = 0
    m
    = 0

    For i = 1 To 10

    If Cells(i, 1).Font.Color = 0 Then '判断字体颜色为黑色
    j = j + 1
    End If

    If Cells(i, 1).Font.Color = 255 Then '判断字体颜色为红色
    k = k + 1
    End If

    If Cells(i, 2).Interior.Color = &HFFFFFF Then '判断背景颜色为白色
    l = l + 1
    End If

    If Cells(i, 2).Interior.Color = &HFF Then '判断背景颜色为红色
    m = m + 1
    End If

    Next i

    Dim FC, BC As String

    FC
    = "Red = " & k & ",Black = " & j
    MsgBox (FC)

    BC
    = "White = " & l & ",Red = " & m
    MsgBox (BC)
    End Sub

  • 相关阅读:
    数据对象映射模式
    策略模式
    适配模式
    注册模式
    单例模式
    工厂模式
    PHP魔法方法的使用
    【转】通过 ulimit 改善系统性能
    HDMI相关知识
    中国三种3G网络频段
  • 原文地址:https://www.cnblogs.com/dabiao/p/1815941.html
Copyright © 2011-2022 走看看