关闭。这个问题需要details or clarity .它目前不接受答案。
想改进这个问题?通过 editing this post 添加详细信息并澄清问题.
4年前关闭。
Improve this question
问题:
对于没有下一个
客观的:
编辑澄清 11/2 下午 4:00
Sub closedsheet()
Application.ScreenUpdating = False
Dim datasheet As Worksheet 'where is the data copied from
Dim closedsheet As Worksheet 'where is the data pasted to
Dim strPhase() As String
Dim i As Integer
Dim intPhaseMax As Integer
Dim lngLstRow As Long
Dim rngCell As Range
Dim finalrow As Integer
Dim lr As Long 'row counter
Dim Looper As Integer
intPhaseMax = 6
ReDim strPhase(1 To intPhaseMax)
strPhase(1) = "LOST"
strPhase(2) = "BAD"
strPhase(3) = "UNINTERESTED"
strPhase(4) = "UNRELATED"
strPhase(5) = "UNDECIDED"
strPhase(6) = "BUDGET"
'set variables
Set datasheet = Sheet1
Set closedsheet = Sheet2
lr = Range("A" & Rows.Count).End(xlUp).Row
For Looper = LBound(strPhase) To UBound(strPhase)
For i = lr To 6 Step -1
If Not Sheet1.Range("L8:L300" & lngLstRow).Find(strPhase(Looper), lookat:=xlWhole) Is Nothing Then
Range(Cells(i, 1), Cells(i, 20)).Copy
Sheet2.Range("A" & Rows.Count).End(3)(2).PasteSpecial xlPasteValues
Range(Cells(i, 1), Cells(i, 20)).Delete
End If
Next
Sheet2.columns.AutoFit
Application.CutCopyMode = False
Application.ScreenUpdating = True
Sheet2.Select
Sheet2.ListObjects.Add(xlSrcRange, Range("A9:U" & lr), , xlYes).Name =
"tblClosed"
End Sub
最佳答案
该答案解决了您上一条评论中的问题。
Dim Looper as Integer
For Looper = Lbound(strPhase) to Ubound(strPhase)
If Not Range("L8:L" & lngLstRow).Find(strPhase(Looper),lookat:=xlWhole) Is Nothing Then
'copy paste code ....
End If
Next
关于vba - 编译错误 : For Without Next | Moving row to separate worksheet based on string values in column,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47080358/