gpt4 book ai didi

excel - 相同的代码不适用于新参数

转载 作者:行者123 更新时间:2023-12-04 20:43:42 26 4
gpt4 key购买 nike

如果相关的水费和电费账单延迟一个月或更长时间,我正在尝试让此代码粘贴房屋 #。我有这个完全相同的代码在同一个工作簿(尽管不同的工作表)中使用另一组类似的数据运行得非常好,但是我在指示的行上得到“Run.time error '1004': Application-defined or object-defined error”当我运行它时。为什么这段代码在这些情况下不起作用?

'General Variables
Dim myDate As Integer
Dim getDate As String
Dim colPaste As String
Dim colPensionNumb As String
Dim colPaste3 As String
Dim colPaste2 As String
Dim colCelular As String
Dim colPaste4 As String
Dim colPaste5 As String

'Agua Variables
Dim aguaNumb As Integer
Dim aguaNumb2 As Integer
Dim colNameAgua As String
Dim colPasteA As String

'Luz Variables
Dim luzNumb As Integer
Dim luzNumb2 As Integer
Dim colNameLuz As String
Dim colPasteL As String

'General Values
colPaste = "A"
colCelular = "G"
colPensionNumb = "H"
myDate = Month(Date)
colPaste3 = "E"
colPaste4 = "F"
colPaste5 = "G"

'Agua Values
colNameAgua = "C"
colPasteA = "B"

'Luz Values
colNameLuz = "D"
colPasteL = "C"


'Agua
For aguaNumb = 3 To 5
If Month(Worksheets("Proxima Lectura").Range(colNameAgua & aguaNumb).Value) < myDate - 1 Then
' ---------THE FOLLOWING LINE IS WHERE THE ERROR OCCURS------------
Worksheets("Title Page").Range(colPasteA & aguaNumb).Value = Worksheets("Proxima Lectura").Range(colNameAgua & aguaNumb).Value
End If
Next aguaNumb

编辑

现在代码没有给我一个错误,但它没有给我 IF 语句中的行的任何结果

最佳答案

在您的评论中,您说单元格“C3”= 26-08-2014 “C4”空白“C5”19-08-2014。所以...当您运行宏时,它当然会跳过 IF代码,因为月份是八月,不满足 IF健康)状况。

尝试您的代码提取,但日期在“C3”= 26-06-2014、“C4”= 26-05-2014、“C5”= 26-03-2014。我想你会发现它有效。

关于excel - 相同的代码不适用于新参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25515913/

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