gpt4 book ai didi

excel - Visual Basic 编译器错误

转载 作者:行者123 更新时间:2023-12-02 14:13:33 25 4
gpt4 key购买 nike

我在下面的编码中收到了一个错误,标记为“需要对象”。请帮帮我。 Temp文件的意思是一个模板,详细信息来源于Combo代码,即模板中需要填写的数据,并根据下面的代码发送电子邮件。

Sub Emails()
Dim R_No As Integer

Templ.Select
Templ.Range("C11") = ""
Templ.Range("D11") = ""
Templ.Range("E11") = ""
Temp1.Range("F11") = "" <-------- Error
Temp1.Range("G11") = ""
Templ.Range("C14") = ""
Templ.Range("D14") = ""
Templ.Range("E14") = ""
Temp1.Range("F14") = ""
Temp1.Range("G14") = ""
Rows("10:11").Select
Selection.EntireRow.Hidden = True
Rows("13:14").Select
Selection.EntireRow.Hidden = True

R_No = 2
Do Until Combo.Cells(R_No, 1) = ""
If Combo.Cells(R_No, 1) = "Order" Then
Combo.Cells(R_No, 13) = Combo.Cells(R_No, 2)
Else
Combo.Cells(R_No, 13) = Combo.Cells(R_No, 2) & " & " & Combo.Cells(R_No, 4)
End If

If Combo.Cells(R_No, 7) = Combo.Cells(R_No + 1, 7) Then
If Combo.Cells(R_No, 1) = Combo.Cells(R_No + 1, 1) Then
If Combo.Cells(R_No, 1) = "Order" Then
Rows("10:11").Select
Selection.EntireRow.Hidden = False
If Templ.Range("C11") = "" Then
Templ.Range("C11") = Combo.Cells(R_No, 2)
Templ.Range("D11") = Combo.Cells(R_No, 3)
Templ.Range("E11") = Combo.Cells(R_No, 5)
Temp1.Range("F11") = Combo.Cells(R_No, 6)
Temp1.Range("G11") = Combo.Cells(R_No, 9)
Else
Templ.Range("C11") = Templ.Range("C11") & Templ.Range("I2") & Combo.Cells(R_No, 2)
Templ.Range("D11") = Templ.Range("D11") & Templ.Range("I2") & Combo.Cells(R_No, 3)
Templ.Range("E11") = Templ.Range("E11") & Templ.Range("I2") & Combo.Cells(R_No, 5)
Templ.Range("F11") = Templ.Range("F11") & Templ.Range("I2") & Combo.Cells(R_No, 6)
Templ.Range("G11") = Templ.Range("G11") & Templ.Range("I2") & Combo.Cells(R_No, 9)
End If
End If
If Combo.Cells(R_No, 1) = "Receipt" Then
Rows("13:14").Select
Selection.EntireRow.Hidden = False
If Templ.Range("C14") = "" Then
Templ.Range("C14") = Combo.Cells(R_No, 2) & "-" & Combo.Cells(R_No, 4)
Templ.Range("D14") = Combo.Cells(R_No, 3)
Templ.Range("E14") = Combo.Cells(R_No, 5)
Temp1.Range("F14") = Combo.Cells(R_No, 6)
Temp1.Range("G14") = Combo.Cells(R_No, 9)
Else
Templ.Range("C14") = Templ.Range("C14") & Templ.Range("I2") & Combo.Cells(R_No, 2) & "-" & Combo.Cells(R_No, 4)
Templ.Range("D14") = Templ.Range("D14") & Templ.Range("I2") & Combo.Cells(R_No, 3)
Templ.Range("E14") = Templ.Range("E14") & Templ.Range("I2") & Combo.Cells(R_No, 5)
Templ.Range("F14") = Templ.Range("F14") & Templ.Range("I2") & Combo.Cells(R_No, 6)
Templ.Range("G14") = Templ.Range("G14") & Templ.Range("I2") & Combo.Cells(R_No, 9)
End If
End If
Else
If Combo.Cells(R_No, 1) = "Order" Then
Rows("10:11").Select
Selection.EntireRow.Hidden = False
If Templ.Range("C11") = "" Then
Templ.Range("C11") = Combo.Cells(R_No, 2)
Templ.Range("D11") = Combo.Cells(R_No, 3)
Templ.Range("E11") = Combo.Cells(R_No, 5)
Temp1.Range("F11") = Combo.Cells(R_No, 6)
Temp1.Range("G11") = Combo.Cells(R_No, 9)
Else
Templ.Range("C11") = Templ.Range("C11") & Templ.Range("I2") & Combo.Cells(R_No, 2)
Templ.Range("D11") = Templ.Range("D11") & Templ.Range("I2") & Combo.Cells(R_No, 3)
Templ.Range("E11") = Templ.Range("E11") & Templ.Range("I2") & Combo.Cells(R_No, 5)
Templ.Range("F11") = Templ.Range("F11") & Templ.Range("I2") & Combo.Cells(R_No, 6)
Templ.Range("G11") = Templ.Range("G11") & Templ.Range("I2") & Combo.Cells(R_No, 9)
End If
End If
If Combo.Cells(R_No, 1) = "Receipt" Then
Rows("13:14").Select
Selection.EntireRow.Hidden = False
If Templ.Range("C14") = "" Then
Templ.Range("C14") = Combo.Cells(R_No, 2) & "-" & Combo.Cells(R_No, 4)
Templ.Range("D14") = Combo.Cells(R_No, 3)
Templ.Range("E14") = Combo.Cells(R_No, 5)
Temp1.Range("F14") = Combo.Cells(R_No, 6)
Temp1.Range("G14") = Combo.Cells(R_No, 9)
Else
Templ.Range("C14") = Templ.Range("C14") & Templ.Range("I2") & Combo.Cells(R_No, 2) & "-" & Combo.Cells(R_No, 4)
Templ.Range("D14") = Templ.Range("D14") & Templ.Range("I2") & Combo.Cells(R_No, 3)
Templ.Range("E14") = Templ.Range("E14") & Templ.Range("I2") & Combo.Cells(R_No, 5)
Templ.Range("F14") = Templ.Range("F14") & Templ.Range("I2") & Combo.Cells(R_No, 6)
Templ.Range("G14") = Templ.Range("G14") & Templ.Range("I2") & Combo.Cells(R_No, 9)
End If
End If
End If
Else
If Combo.Cells(R_No, 1) = "Order" Then
Rows("10:11").Select
Selection.EntireRow.Hidden = False
If Templ.Range("C11") = "" Then
Templ.Range("C11") = Combo.Cells(R_No, 2)
Templ.Range("D11") = Combo.Cells(R_No, 3)
Templ.Range("E11") = Combo.Cells(R_No, 5)
Temp1.Range("F11") = Combo.Cells(R_No, 6)
Temp1.Range("G11") = Combo.Cells(R_No, 9)
Else
Templ.Range("C11") = Templ.Range("C11") & Templ.Range("I2") & Combo.Cells(R_No, 2)
Templ.Range("D11") = Templ.Range("D11") & Templ.Range("I2") & Combo.Cells(R_No, 3)
Templ.Range("E11") = Templ.Range("E11") & Templ.Range("I2") & Combo.Cells(R_No, 5)
Templ.Range("F11") = Templ.Range("F11") & Templ.Range("I2") & Combo.Cells(R_No, 6)
Templ.Range("G11") = Templ.Range("G11") & Templ.Range("I2") & Combo.Cells(R_No, 9)
End If
End If
If Combo.Cells(R_No, 1) = "Receipt" Then
Rows("13:14").Select
Selection.EntireRow.Hidden = False
If Templ.Range("C14") = "" Then
Templ.Range("C14") = Combo.Cells(R_No, 2) & "-" & Combo.Cells(R_No, 4)
Templ.Range("D14") = Combo.Cells(R_No, 3)
Templ.Range("E14") = Combo.Cells(R_No, 5)
Temp1.Range("F14") = Combo.Cells(R_No, 6)
Temp1.Range("G14") = Combo.Cells(R_No, 9)
Else
Templ.Range("C14") = Templ.Range("C14") & Templ.Range("I2") & Combo.Cells(R_No, 2) & "-" & Combo.Cells(R_No, 4)
Templ.Range("D14") = Templ.Range("D14") & Templ.Range("I2") & Combo.Cells(R_No, 3)
Templ.Range("E14") = Templ.Range("E14") & Templ.Range("I2") & Combo.Cells(R_No, 5)
Templ.Range("F14") = Templ.Range("F14") & Templ.Range("I2") & Combo.Cells(R_No, 6)
Templ.Range("G14") = Templ.Range("G14") & Templ.Range("I2") & Combo.Cells(R_No, 9)
End If
End If
Templ.Range("C6") = "Dear " & Left(Combo.Cells(R_No, 7), InStr(1, Combo.Cells(R_No, 7), " ") - 1) & ","
Templ.Range("A1:H48").Select
ThisWorkbook.EnvelopeVisible = False
ThisWorkbook.EnvelopeVisible = True

With ThisWorkbook.Sheets("Templete").MailEnvelope
.Item.Subject = "Reminder- Order(s) / Receipt(s) Pending Your Urgent Approval"
.Item.To = Combo.Cells(R_No, 8)
.Item.cc = " "
If Combo.Cells(R_No, 10) <> "" Then
.Item.cc = Combo.Cells(R_No, 12)
Else
End If
.Item.Send

Templ.Range("C11") = ""
Templ.Range("D11") = ""
Templ.Range("E11") = ""
Templ.Range("F11") = ""
Templ.Range("G11") = ""
Templ.Range("C14") = ""
Templ.Range("D14") = ""
Templ.Range("E14") = ""
Templ.Range("F14") = ""
Templ.Range("G14") = ""

Rows("10:11").Select
Selection.EntireRow.Hidden = True
Rows("13:14").Select
Selection.EntireRow.Hidden = True
End With
End If
R_No = R_No + 1
Loop
End Sub

最佳答案

F11 语句有 temp1 {ONE} 而不是 TEMPL。 G11也是如此

Templ.Range("E11") = ""
Temp1.Range("F11") = ""

关于excel - Visual Basic 编译器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15007171/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com