繁体   English   中英

如何选择范围的一部分

[英]how to select a section of ranges

要在AP列中分配xx,我必须检查一些字段,在xx分配之前必须填写它们

我试图将一些列分配给一个变量,但我对该变量进行了控制,但似乎不起作用

我在这条线上有一个错误

Set MaPlage = Columns("A:R" & "W:E").Rows(i)

这是我的代码:

Sub Decision()


Dim cell As Range

Dim i As Integer
Dim j As Integer
Dim x As Integer
Dim y As Integer
Dim z As Integer
Dim u As Integer
Dim t As Integer
        Dim l As Integer
        Dim p As Integer

        Set MaPlage = Columns("A:R" & "W:E").Rows(i)

 For i = 2 To ActiveSheet.Cells(ActiveSheet.Rows.Count, 1).End(xlUp).Row
    If CStr(ActiveSheet.Cells(i, 31).Value) = "Completed - Appointment made / Complété - Nomination faite" And (ActiveSheet.MaPlage.Value) = "<>" Then

        If CStr(ActiveSheet.Cells(i, 14).Value) = "AEP" _
            Or CStr(ActiveSheet.Cells(i, 14).Value) = "CMC_REV" _
            Or CStr(ActiveSheet.Cells(i, 14).Value) = "CMC_APT" _
            Or CStr(ActiveSheet.Cells(i, 14).Value) = "CS_TPD" _
            Or CStr(ActiveSheet.Cells(i, 14).Value) = "DM_ID" Then

                         ActiveSheet.Cells(i, 42).Value = "XX"
        End If


    End If

Next i

合并所有注释,请尝试以下操作:

For i = 2 To ActiveSheet.Cells(ActiveSheet.Rows.Count, 1).End(xlUp).Row
    Set maplage = Range("A" & i & ":H" & i & ",J" & i & ":R" & i & ",W" & i & ":Z" & i & ",AA" & i & ":AO" & i)
    If UCase(Left(ActiveSheet.Cells(i, 31).Value), 3) = "COM" _
         And WorksheetFunction.Countif(MaPlage,"") = 0 Then
        Select Case UCase(Left(ActiveSheet.Cells(i, 14).Value), 3)
            Case "AEP", "CMC", "CS_", "DM_"
                ActiveSheet.Cells(i, 42).Value = "XX"
        End Select
    End If
Next i

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM