|
楼主 |
发表于 2012-4-13 10:47
|
显示全部楼层
无聊的疯子 发表于 2012-4-13 10:27
提供具体的附件来说明你的情况!!
一般来说,这种情况直接使用公式就行了的,就没必要非得把问题搞那么 ...
例如:这条程序:简单介绍是,我要做一个文件收发窗口,在收发窗口的表格sheet1中将(5,6)、(5,7)、(5、8)……(5、12)单元格中的信息,输入到sheet2文件收发记录表格中(x,1)、(x,2)……(x,8)中去(x是判断这条记录是否是空的,当这条记录为空的时候填写进去,不为空的时候自动跳到下一行去),在文件收发窗口中,我要在(5,6)和(5,7)间插入一列,补充信息,后面的所有信息都要加1,如Sheet1.Cells(5, 6),变成Sheet1.Cells(5, 7),程序如下所示,已经调试成功了。
但是很麻烦呀?请老师指点~
Sub 文件发出()
Dim x As Integer
Sheet1.Cells(11, 10).ClearContents
If Sheet1.Cells(5, 6) = "" Or Sheet1.Cells(5, 7) = "" Or Sheet1.Cells(5, 8) = "" Or Sheet1.Cells(5, 9) = "" Or Sheet1.Cells(5, 10) = "" Or Sheet1.Cells(5, 11) = "" Or Sheet1.Cells(5, 12) = "" Then
Sheet1.Cells(11, 10) = "请输入完整信息"
End If
x = 1
Do
x = x + 1
If Sheet1.Cells(11, 10) <> "请输入完整信息" And Sheet2.Cells(x, 1) = "" And Sheet2.Cells(x, 2) = "" And Sheet2.Cells(x, 3) = "" And Sheet2.Cells(x, 4) = "" And Sheet2.Cells(x, 5) = "" And Sheet2.Cells(x, 6) = "" And Sheet2.Cells(x, 7) = "" And Sheet2.Cells(x, 8) = "" Then
Sheet2.Cells(x, 1) = Sheet1.Cells(5, 6)
Sheet2.Cells(x, 2) = Sheet1.Cells(5, 7)
Sheet2.Cells(x, 3) = Sheet1.Cells(5, 8)
Sheet2.Cells(x, 4) = Sheet1.Cells(5, 9)
Sheet2.Cells(x, 5) = Sheet1.Cells(5, 10)
Sheet2.Cells(x, 6) = Sheet1.Cells(5, 11)
Sheet2.Cells(x, 7) = Sheet1.Cells(5, 12)
Sheet2.Cells(x, 8) = Sheet1.Cells(5, 13)
Exit Do
End If
Loop Until x = 10000
If Sheet1.Cells(11, 10) = "" Then
Sheet1.Cells(11, 10) = "输入成功"
End If
If Sheet1.Cells(11, 10) <> "请输入完整信息" Then
Sheet1.Cells(5, 6).ClearContents
Sheet1.Cells(5, 7).ClearContents
Sheet1.Cells(5, 8).ClearContents
Sheet1.Cells(5, 9).ClearContents
Sheet1.Cells(5, 10).ClearContents
Sheet1.Cells(5, 11).ClearContents
Sheet1.Cells(5, 12).ClearContents
Sheet1.Cells(5, 13).ClearContents
End If
End Sub
|
|