zoukankan      html  css  js  c++  java
  • vba 对Excel 表格的操作

    vba 基础语法:

    变量的定义:

    变量:Dim   xxdim xx,mm    dim  xxx  as string

    定义常量 :const x  

    数据类型

    dim x

    x = array("xx","yy")

     循环

    for i = 1 to 

    嘻嘻嘻

    next

    for each j  in xxx

    xxxx

    next

    do while xxx

    xxx

    exit do 跳出循环

    loop

    if 判断

    if  xxx  then

    end if 

    if xxx  then  else  end if 

    函数调用 

    sub test(x)

    xxxx

    end sub 

    test  x

    function demo()

    xx

    end function

    demo()

    异常处理:

    on error goto error_miaoshu

    xxxxx

    error_miaoshu     异常处理直接跳到指定的地方

    on error resume next   遇到报错,直接走下一行

    excle

    根据表名获取对象:  set  sheet_obj = sheets("表名")   sheet_obj.cells(1,1) = 8

    当列的有效行数: max = sheet_obj.cells(rows.count,"G").end(xlup).row  

    当行有效列数; ma小 = sheet_obj.cells(5,columns.count).end(xlup).column

    整个表有效行数:sheet_obj.usedrange.rows.count

    整个表有效列数:sheet_obj.usedrange.columns.count

    一列 数据对象:dim arr as variant

    arr = range("A5:A100")

  • 相关阅读:
    数据查询
    泰勒展开及其应用
    搜索排序算法
    因子分解机 FM
    偏差方差分解
    Softmax 损失-梯度计算
    目标检测网络之 Mask R-CNN
    目标检测网络之 R-FCN
    深度学习-conv卷积
    目标检测网络之 YOLOv3
  • 原文地址:https://www.cnblogs.com/LMTlmt/p/13280418.html
Copyright © 2011-2022 走看看