public Sub InserDb()

dim maxrow as integer

dim maxcol as integer

dim ddl as string

dim recode as string

dim recodes as string

dim sheetname as string

dim tablename as string

sheetname = "data"

tablename  = sheets(sheetname).cells(1,2).value

maxrow = sheets(sheetname).cells(rows.count,1).end(xlup).row

maxcol = sheets(sheetname).cells(2,columns.count).end(xltoleft).column

for i = 1 to maxcol

  if i = 1 then

    ddl = sheets(sheetname).cells(2,i).value

  else

    ddl = ddl + "," + sheets(sheetname).cells(2,i).value

  end if

next

for j = 3 to maxrow

  for k = 1 to maxcol

    if k = 1 then

      recode = "(" & "'" & sheets(sheetname).cells(j,k).value & "'"

    else

      if sheets(sheetname).cells(j,k).value = "" then

        recode = recode & "," & "NULL"

      else

        recode = recode & "," & "'" & sheets(sheetname).cells(j,k).value & "'"

      end if

    end if

  next

  sheets("output").cells(j-1,1).value = "insert into" & tablename & "(" & dll & ")" & "values" & recode + ");"

next

sheets("output").cells(1,1).value = "TRUNCATE" & tablename & ";"

sheets("output").select

end sub

vba data to input tool的更多相关文章

  1. sc.textFile("file:///home/spark/data.txt") Input path does not exist解决方法——submit 加参数 --master local 即可解决

    use this val data = sc.textFile("/home/spark/data.txt") this should work and set master as ...

  2. golang illegal base64 data at input byte

    //one reason is whitespace ciphertext = strings.Replace(ciphertext, " ", "", -1) ...

  3. PatentTips - Data Plane Packet Processing Tool Chain

    BACKGROUND The present disclosure relates generally to systems and methods for providing a data plan ...

  4. DATA VISUALIZATION – PART 2

    A Quick Overview of the ggplot2 Package in R While it will be important to focus on theory, I want t ...

  5. What is Data Driven Testing? Learn to create Framework

    What is Data Driven Testing? Data-driven is a test automation framework which stores test data in a ...

  6. [LeetCode] Data Stream as Disjoint Intervals 分离区间的数据流

    Given a data stream input of non-negative integers a1, a2, ..., an, ..., summarize the numbers seen ...

  7. jquery判断多个input输入框不能输入相同的值

    function checkName(data){ //校验联系信息不能一致 var values=""; $(".t").each(function(i,it ...

  8. TRANSPOSE的DATA步实现

    data a; input name $ a b ; cards; x x x y y y ; run; %macro transpose; proc sql noprint ; select cou ...

  9. Leetcode: Data Stream as Disjoint Intervals && Summary of TreeMap

    Given a data stream input of non-negative integers a1, a2, ..., an, ..., summarize the numbers seen ...

随机推荐

  1. 字符编码 ASCII、Unicode和UTF-8的关系

    摘抄自廖雪峰 教程 字符编码 我们已经讲过了,字符串也是一种数据类型,但是,字符串比较特殊的是还有一个编码问题. 因为计算机只能处理数字,如果要处理文本,就必须先把文本转换为数字才能处理.最早的计算机 ...

  2. 静态方法和实例方法(mark)

    借花献佛[转自 ivony's blog] 关于静态方法和实例方法的一些误区. 一.    静态方法常驻内存,实例方法不是,所以静态方法效率高但占内存.     事实上,方法都是一样的,在加载时机和占 ...

  3. Shadow Properties之美(二)【Microsoft Entity Framework Core随笔】

    接着上一篇Shadow Properties之美(一),我们来继续举一个有点啰嗦的栗子. 先看简单需求:某HR系统,需要记录员工资料.需要记录的资料有: 员工号(规则:分公司所在城市拼音首字母,加上三 ...

  4. C++算法之大数加法计算的代码

    如下代码段是关于C++算法之大数加法计算的代码,希望对大家有用. { int length; int index; int smaller; int prefix = 0; if(NULL == sr ...

  5. 递归----Python

    #递归不仅仅是学习python中会遇到的一些问题,在学习每一个语言的过程中都会遇到递归.使用递归可以让复杂的循环变得简单. 递归:程序调用自身的行为 1.写一个数的阶乘 #递归 def factor( ...

  6. 踩坑学习python自动化测试第二天!

    class put_out(object): def Helloword(str): print(str) Hello,Inder,Pist ="", [],{} word= st ...

  7. docker学习构建镜像---第三章节

    一.docker镜像使用 运行docker容器时,使用的镜像如果在本地不存在,docker会自动从docker镜像仓库中下载,默认是从docker hub公共镜像源下载 在这里,我们需要了解:管理和使 ...

  8. 汉诺塔I

    题目描述 对于传统的汉诺塔游戏我们做一个拓展,我们有从大到小放置的n个圆盘,开始时所有圆盘都放在左边的柱子上,按照汉诺塔游戏的要求我们要把所有的圆盘都移到右边的柱子上,请实现一个函数打印最优移动轨迹. ...

  9. 为什么使用Nosql:Nosql和SQL的区别

    1.概念: SQL(Structured Query Language)数据库,指关系型数据库.主要代表:SQL Server.Oracle.MySQL.PostgreSQL. NoSQL(Not O ...

  10. 原型图 ER 8.0的注册码

    axuer8.0注册码Licensee:米 业成 (STUDENT)Key:nFmqBBvEqdvbiUjy8NZiyWiRSg3yO+PtZ8c9wdwxWse4WprphvSu9sohAdpNnJ ...