EXCEL VBA窗体化编程 您所在的位置:网站首页 excelvba窗体录入数据实例 EXCEL VBA窗体化编程

EXCEL VBA窗体化编程

2022-05-20 19:20| 来源: 网络整理| 查看: 265

15

15、要过程中输入如下代码:

Dim k As Integer

With ThisWorkbook.Sheets("sheet1")

     If .Cells(1, 1) = "" Then

         .Cells(1, 1) = "日期"

         .Cells(1, 2) = "摘要"

         .Cells(1, 3) = "借方"

         .Cells(1, 4) = "贷方"

         .Cells(1, 5) = "余额"

     End If

End With

k = ThisWorkbook.Sheets("sheet1").End(xlUp).Row

With ThisWorkbook.Sheets("sheet1")

     .Cells(k + 1, 1) = CDate(Me.TextBox1.Value)

     .Cells(k + 1, 2) = Me.TextBox2.Value

     If Me.TextBox3.Value = "收" Then

        .Cells(k + 1, 3) = Val(Me.TextBox4.Value)

     Else

        .Cells(k + 1, 4) = Val(Me.TextBox4.Value)

     End If

     If k = 1 Then

        .Cells(k + 1, 5) = Val(.Cells(k + 1, 3)) - Val(.Cells(k + 1, 4))

     Else

        .Cells(k + 1, 5) = Val(.Cells(k + 1, 3)) - Val(.Cells(k + 1, 4)) + Val(.Cells(k, 5))

     End If

End With

MsgBox "本笔已录入"

不容质疑我的代码是否正确,绝对运行正常(我编程14年以上,熟练)效果如下:



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有