• vba比较日期大小,定义日期;vba让excel保存


    Private Sub CommandButton1_Click()
    Dim i, j As Integer
    Dim a As Date
    a = #10/1/2013#
    j = 2
    i = 2
    ' If  Worksheets("改后B").Range("a" & CStr(i)) = Worksheets("改后A").Range("a" & CStr(j)) And Worksheets("改后B").Range("b" & CStr(i)) = Worksheets("改后A").Range("b" & CStr(j)) And Trim(Worksheets("改后B").Range("c" & CStr(i))) = Trim(Worksheets("改后A").Range("c" & CStr(j))) And Trim(Worksheets("改后B").Range("d" & CStr(i))) = Trim(Worksheets("改后A").Range("d" & CStr(j))) Then
    '  MsgBox DateDiff("d", Worksheets("改后B").Range("a" & CStr(560)), 2013 - 10 - 1)
      'End If

    For i = 2801 To 3500
      j = 2
       While Worksheets("改后A").Range("a" & CStr(j)) <> ""
       
         If Worksheets("改后B").Range("a" & CStr(i)) < a Then
          If Worksheets("改后B").Range("a" & CStr(i)) = Worksheets("改后A").Range("a" & CStr(j)) And Worksheets("改后B").Range("b" & CStr(i)) = Worksheets("改后A").Range("b" & CStr(j)) And Trim(Worksheets("改后B").Range("c" & CStr(i))) = Trim(Worksheets("改后A").Range("c" & CStr(j))) And Trim(Worksheets("改后B").Range("d" & CStr(i))) = Trim(Worksheets("改后A").Range("d" & CStr(j))) Then
            Worksheets("改后B").Range("p" & i) = Worksheets("改后A").Range("e" & j)
            Worksheets("改后B").Range("q" & i) = Worksheets("改后A").Range("f" & j)
            Worksheets("改后B").Range("r" & i) = Worksheets("改后A").Range("g" & j)
            Worksheets("改后B").Range("s" & i) = Worksheets("改后A").Range("h" & j)
            Worksheets("改后B").Range("t" & 2) = i
            If i Mod 100 = 0 Then
               ThisWorkbook.Save
            End If
    GoTo ee
          End If
        End If
         If Worksheets("改后B").Range("a" & CStr(i)) > a Then                             比较日期
             Worksheets("改后B").Range("t" & i) = "日期大于表A最大日期"
             Worksheets("改后B").Range("t" & 2) = i
             If i Mod 100 = 0 Then
       保存        ThisWorkbook.Save    
            End If
    GoTo ee
         End If
        j = j + 1
       Wend
    ee:
    Next
    End Sub

  • 相关阅读:
    最简单的界面建立
    滚动字幕的建立(事件的监听,定时器)
    【转】centOS上安装redis+phpredis2.2.4扩展
    【转】文件恢复神器extundelete
    CentOS 漏洞修补
    [转]给Linux系统管理员准备的Nmap命令的29个实用范例+ tsysv 系统服务器管理器
    [转]linux下iftop工具的安装与使用详解(图文)——实时的网络流量,监控TCP/IP连接(单机)
    [转]tripwire-文件指纹
    [转]svn提交自动同步到web服务器
    [转]CentOS_yum的详细使用方法
  • 原文地址:https://www.cnblogs.com/liudong/p/3372970.html
Copyright © 2020-2023  润新知