|
楼主 |
发表于 2012-6-3 22:42
|
显示全部楼层
其实下面这个代码,我还有一个条件需要判断的。条件一:If Sheet1.Range("A1") = "3" And Sheet1.Range("G34") = "申请样书" Then
还有一个条件二 If Sheet1.Range("A1") = "3" And Sheet1.Range("G34") = "申请样书和课件(以及密码)" Then。只要这两个条件任何一个实现,都会执行下面的代码。
Sub 自动保存()
Dim aa$, bb$
Dim Lastrow As Long
Dim Insertrow As Long
Lastrow = Sheet2.Range("E65536").End(xlUp).Row
Insertrow = Lastrow + 1
'判断版本以及自动录入样书赠书信息
If Sheet1.Range("A1") = "3" And Sheet1.Range("G34") = "申请样书" Then '录入姓名,邮寄地址,邮编等基本信息
Sheet2.Cells(Insertrow, 1) = Sheet1.Range("c8")
Sheet2.Cells(Insertrow, 2) = Sheet1.Range("I12") & Sheet1.Range("C13") & Sheet1.Range("E13") & Sheet1.Range("C9") & Sheet1.Range("G9") & Sheet1.Range("C10")
Sheet2.Cells(Insertrow, 3) = Sheet1.Range("G12")
'录入办公电话以及手机(合并)
If Sheet1.Range("G11") <> "" Then
aa = Sheet1.Range("G11") & "、"
Else: aa = ""
End If
If Sheet1.Range("C11") <> "" Then
bb = Sheet1.Range("C11") & Sheet1.Range("D11") & "、"
Else: bb = ""
End If
Sheet2.Cells(Insertrow, 4) = Left(aa & bb, Len(aa & bb) - 1)
Sheet2.Cells(Insertrow, 7) = Sheet1.Range("I36")
Sheet2.Cells(Insertrow, 8) = "1"
Sheet2.Cells(Insertrow, 9) = Date
Sheet2.Cells(Insertrow, 11) = Sheet1.Range("C38")
Sheet2.Cells(Insertrow, 12) = Sheet1.Range("G10")
'赠书信息
Sheet2.Cells(Insertrow, 5) = Sheet1.Range("B34")
Sheet2.Cells(Insertrow, 6) = Sheet1.Range("C34")
If Sheet1.Range("G35") = "申请样书" Or Sheet1.Range("G35") = "申请样书和课件(以及密码)" Then
Sheet2.Cells(Insertrow + 1, 5) = Sheet1.Range("B35")
Sheet2.Cells(Insertrow + 1, 6) = Sheet1.Range("C35")
Sheet2.Cells(Insertrow + 1, 7) = Sheet1.Range("I36")
Sheet2.Cells(Insertrow + 1, 8) = "1"
Sheet2.Cells(Insertrow + 1, 9) = Date
Sheet2.Cells(Insertrow + 1, 12) = Sheet1.Range("G10")
End If
End If
End Sub |
|