如何选择范围的一部分 [英] how to select a section of ranges

查看:78
本文介绍了如何选择范围的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

To assign xx in the AP column, i have to check some fields that they must be filled before the xx assignment

我尝试将某些列分配给变量并且我对该变量进行了控制,但似乎不起作用

i tried to assign some columns to a variable and i did the control to that variable, but it seems like it doesn't work

我在此行遇到了错误

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


推荐答案

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

Combining all the comments try this:

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

这篇关于如何选择范围的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆