I am getting 1004 error: for lines
我收到1004错误:换行
lstktxt = Cells(lstusefulentry, 12).Value & Cells(lstusefulentry, 13).Value & _
Cells(lstusefulentry, 14).Value
and
nextktext = Cells(nextentry, 12).Value & Cells(nextentry, 13).Value & _
Cells(nextentry, 14).Value
Can you think of why? Thanks
你能想到为什么吗?谢谢
Edit:
Thanks for the responses. Here is my full macro code.
谢谢你的回复。这是我的完整宏代码。
Any idea where I am introducing the error? nextktext and lstktxt are defined as strings, and lstusefulentry and nextentry are appropriately defined.
知道我在哪里引入错误吗? nextktext和lstktxt被定义为字符串,并且lstusefulentry和nextentry被适当地定义。
Sub processTXT()
'
' processTXT Macro
'
'
Dim last As Integer, lstentry As String, lstusefulentry As Integer, lstktxt As
String, lastknrextract As Variant, lastknr As Integer, lastkidend As
Integer, lstrelvntrow As Integer, lastkid As String, kid As String, knr As
Integer, nextrelvntrow As Integer, nextentry As Integer, nextktext As
String, nextknrextract As Variant, nextkidend As Integer
last = Range("L" & Rows.Count).End(xlUp).Row
lstentry = Left(Cells(last, 12).Value, 5)
If lstentry = "VOC5B" Then
lstusefulentry = (last - 16)
lstrelvntrow = (lstusefulentry + 8)
Else
MsgBox "Error!"
End If
lstktxt = Cells(lstusefulentry, 12).Value & Cells(lstusefulentry, 13).Value &
Cells(lstusefulentry, 14).Value
lastknrextract = Mid(lstktxt, 12, 3)
If IsNumeric(lastknrextract) Then
lastknr = CInt(lastknrextract)
Else
MsgBox "Error!"
End If
lastkidend = InStr(lstktxt, "end")
lastkid = Trim(Mid(lstktxt, 15, (lastkidend - 15)))
knr = lastknr
kid = lastkid
nextrelvntrow = lstrelvntrow
nextentry = lstusefulentry
nextktext = ""
Do While knr >= 1
Cells(knr + 3, 18).Value = kid
Cells(knr + 3, 19).Value = Cells(nextrelvntrow, 14).Value
nextentry = nextentry - 16
nextrelvntrow = nextentry + 8
nextktext = Cells(nextentry, 12).Value & Cells(nextentry, 13).Value &
Cells(nextentry, 14).Value
nextknrextract = Mid(nextktext, 12, 3)
knr = CInt(nextknrextract)
nextkidend = InStr(nextktext, "end")
kid = Trim(Mid(nextktext, 15, (nextkidend - 15)))
Loop
End Sub
1 个解决方案
#1
0
lstusefulentry
must be an Integer or Long variable with a value greater than zero and less than or equal to Rows.Count
lstusefulentry必须是Integer或Long变量,其值大于零且小于或等于Rows.Count
#1
0
lstusefulentry
must be an Integer or Long variable with a value greater than zero and less than or equal to Rows.Count
lstusefulentry必须是Integer或Long变量,其值大于零且小于或等于Rows.Count