• GetOpenFilename的基本用法(文件夹实操)


    Sub 数据导入()
    Dim f, arr, i&, j&, k, m%, n%, p%, sh As Workbook
    f = Application.GetOpenFilename(filefilter:="Excel文件(*xls), *xls", Title:="选择Excel文件", MultiSelect:=True)
    If TypeName(f) = "boolean" Then Exit Sub
    Application.ScreenUpdating = False
    Set sh = ThisWorkbook
    sh.Sheets("客户导入样表").UsedRange.Offset(1).Delete
    For i = 1 To UBound(f)
    With GetObject(f(i))
    j = Application.CountA(sh.Sheets("客户导入样表").[b:b])
    .Sheets(1).Range("b4").Copy
    sh.Sheets("客户导入样表").Range("b" & j + 1 & " : " & "c" & j + 1).PasteSpecial Paste:=xlPasteValuesAndNumberFormats
    .Sheets(1).Range("b6").Copy
    sh.Sheets("客户导入样表").Range("d" & j + 1 & " : " & "e" & j + 1).PasteSpecial Paste:=xlPasteValuesAndNumberFormats
    k = .Sheets(1).Range("b7").Value
    m = InStr(1, k, "省")
    n = InStr(1, k, "市")
    p = InStr(1, k, "区")
    sh.Sheets("客户导入样表").Range("r" & j + 1) = Left(k, m)
    sh.Sheets("客户导入样表").Range("g" & j + 1) = Mid(k, m + 1, n - m)
    sh.Sheets("客户导入样表").Range("s" & j + 1) = Mid(k, m + 1, n - m)
    sh.Sheets("客户导入样表").Range("t" & j + 1) = Mid(k, n + 1, p - n)
    sh.Sheets("客户导入样表").Range("v" & j + 1 & " : " & "w" & j + 1) = k
    .Close False
    End With
    Next
    MsgBox "导入完成!"
    Application.ScreenUpdating = True
    End Sub

  • 相关阅读:
    URL模块之parse方法
    结合GET(),POST()实现一个简单、完整的服务器
    Node.js初探之实现能向前台返回东西的简单服务器
    float和position
    回归博客园·共享onload事件
    百度地图api的用法
    美丽数列
    低位值
    删括号
    牛牛找工作
  • 原文地址:https://www.cnblogs.com/shida-liu/p/9242528.html
Copyright © 2020-2023  润新知