Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 1893|回复: 3

[已解决]求教 修改代码

[复制链接]
发表于 2011-1-5 13:38 | 显示全部楼层 |阅读模式
求教 修改代码
最佳答案
2011-1-5 13:46
  1. Sub 保存新增()
  2. Dim intS As Integer, Myr%
  3. Dim rngC As Range
  4. Dim strToFind As String, FirstAddress As String
  5. Dim wSht As Worksheet

  6. 'Application.ScreenUpdating = False

  7. intS = 1
  8. Set wSht = Worksheets("记录")
  9. ' Myr = wSht.[c65536].End(xlUp).Row + 1
  10. For i = 5 To 9
  11. Myr = wSht.[c65536].End(xlUp).Row + 1
  12. If Cells(i, 1) <> "" Then
  13. With wSht
  14. .Cells(Myr, 3) = [c3].Value
  15. '.Cells(Myr, 4) = [f3].Value
  16. .Cells(Myr, 5) = Cells(i, 1)
  17. .Cells(Myr, 6) = Cells(i, 2)
  18. .Cells(Myr, 7) = Cells(i, 3)
  19. .Cells(Myr, 8) = Cells(i, 4)
  20. .Cells(Myr, 9) = Cells(i, 5)
  21. .Cells(Myr, 10) = Cells(i, 6)
  22. .Cells(Myr, 11) = Cells(i, 7)
  23. .Cells(Myr, 12) = Cells(i, 8)
  24. End With
  25. End If
  26. Next i
  27. wSht.Activate
  28. 'Application.ScreenUpdating = True
  29. Sheets("录入").Select
  30. With Sheets("录入")
  31. .Range("a5:b9,d5:h9").ClearContents
  32. .Cells(3, 6) = .Cells(3, 6) + 1
  33. .Cells(3, 3) = Date '加上这句
  34. End With
  35. End Sub
复制代码

求修改代码.rar

21.75 KB, 下载次数: 11

发表于 2011-1-5 13:46 | 显示全部楼层    本楼为最佳答案   
  1. Sub 保存新增()
  2. Dim intS As Integer, Myr%
  3. Dim rngC As Range
  4. Dim strToFind As String, FirstAddress As String
  5. Dim wSht As Worksheet

  6. 'Application.ScreenUpdating = False

  7. intS = 1
  8. Set wSht = Worksheets("记录")
  9. ' Myr = wSht.[c65536].End(xlUp).Row + 1
  10. For i = 5 To 9
  11. Myr = wSht.[c65536].End(xlUp).Row + 1
  12. If Cells(i, 1) <> "" Then
  13. With wSht
  14. .Cells(Myr, 3) = [c3].Value
  15. '.Cells(Myr, 4) = [f3].Value
  16. .Cells(Myr, 5) = Cells(i, 1)
  17. .Cells(Myr, 6) = Cells(i, 2)
  18. .Cells(Myr, 7) = Cells(i, 3)
  19. .Cells(Myr, 8) = Cells(i, 4)
  20. .Cells(Myr, 9) = Cells(i, 5)
  21. .Cells(Myr, 10) = Cells(i, 6)
  22. .Cells(Myr, 11) = Cells(i, 7)
  23. .Cells(Myr, 12) = Cells(i, 8)
  24. End With
  25. End If
  26. Next i
  27. wSht.Activate
  28. 'Application.ScreenUpdating = True
  29. Sheets("录入").Select
  30. With Sheets("录入")
  31. .Range("a5:b9,d5:h9").ClearContents
  32. .Cells(3, 6) = .Cells(3, 6) + 1
  33. .Cells(3, 3) = Date '加上这句
  34. End With
  35. End Sub
复制代码

评分

参与人数 1 +20 收起 理由
tkgg93 + 20 最佳答案奖经验20

查看全部评分

回复

使用道具 举报

发表于 2011-1-5 13:50 | 显示全部楼层
Sub 保存新增()
    Dim intS As Integer, Myr%
    Dim rngC As Range
    Dim strToFind As String, FirstAddress As String
    Dim wSht As Worksheet

    'Application.ScreenUpdating = False

    intS = 1
    Set wSht = Worksheets("记录")
  '  Myr = wSht.[c65536].End(xlUp).Row + 1
    For i = 5 To 9
        Myr = wSht.[c65536].End(xlUp).Row + 1
        If Cells(i, 1) <> "" Then
    With wSht
        .Cells(Myr, 3) = [c3].Value
        '.Cells(Myr, 4) = [f3].Value
        .Cells(Myr, 5) = Cells(i, 1)
        .Cells(Myr, 6) = Cells(i, 2)
        .Cells(Myr, 7) = Cells(i, 3)
        .Cells(Myr, 8) = Cells(i, 4)
        .Cells(Myr, 9) = Cells(i, 5)
        .Cells(Myr, 10) = Cells(i, 6)
        .Cells(Myr, 11) = Cells(i, 7)
        .Cells(Myr, 12) = Cells(i, 8)
    End With
    End If
    Next i
    wSht.Activate
    'Application.ScreenUpdating = True
    Sheets("录入").Select
    With Sheets("录入")
        .Range("a5:b9,d5:h9").ClearContents
        .Cells(3, 6) = .Cells(3, 6) + 1
        .Cells(3, 3) = Format(Now, "yyyy年m月d日")
    End With
   End Sub
回复

使用道具 举报

发表于 2011-1-5 14:01 | 显示全部楼层
学习一下,谢谢。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-9-25 06:08 , Processed in 0.637501 second(s), 10 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表