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. python修炼第六天

    越来越难了....现在啥也不想说了,撸起袖子干. 1 面向对象 先来个例子: 比如人狗大战需要有狗,人所以创建两个类别模子def Person(name,sex,hp,dps): dic = {&qu ...

  2. c# 关于Threading.ApartmentState

    今天在做一个需求 就是 客户端的注销重新登录的操作,想必大家很清楚这个逻辑应该怎么去做, 在主线程里面去调用这个注销的方法 然后关闭当前应用域,重新开一个线程 让应用域在上面执行. STA(singl ...

  3. MFC如何在树形图边上添加动态小地图

    MFC如何在树形图边上添加动态小地图 https://www.jianshu.com/p/7b1d828bf5db (简书无法识别缩进的...早知道先在博客园发了) (转载请注明出处) 作者:梦镜谷雨 ...

  4. c++常量指针和指针常量的区别

    int a:int * const p = &a: //指针常量,*p可以修改*p = 8:(OK) p不可以修改 p++(ERROR) int a,b:const int *p = & ...

  5. [Leetcode 216]求给定和的数集合 Combination Sum III

    [题目] Find all possible combinations of k numbers that add up to a number n, given that only numbers ...

  6. gateway 配置

    server: port: spring: application: name: api-gateway eureka: client: service-url: defaultZone: http: ...

  7. DataGridView中的DataGridViewComboBoxColumn 让其值改变联动

    在工作中自己也遇到过这类问题, 最近也有很多人问我这个问题, 就此机会写出来记录一下. 首先,顾名思义,值改变事件我们会想到 dataGridView1_CellValueChanged 这个事件,想 ...

  8. js之 单例模式

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  9. vue简单的日历

    <ul class="date"> <li v-for="(item, index) in list" :key="index&qu ...

  10. php优秀框架codeigniter学习系列——CI_Input类学习

    这篇文章主要介绍CI核心框架工具类CI_Input. 根据CI文档自己的定义,该类用来: 提前处理全局变量,以保证安全; 提供一些帮助函数用来处理输入数据. 以下选取类中的重点方法进行说明. __co ...