VBA连接动态范围

时间:2016-07-06 18:27:23

标签: vba concatenation select-case

我有一个动态范围,我想使用select case修复一个数据范围,将其粘贴20列,然后连接两列,固定上行范围列和动态范围集中的另一列,将粘贴20列,或粘贴固定范围。

我实际上在连接它们时遇到了麻烦。我有选择案例部分工作,但我不知道如何实际连接它们。

现在我有

Private Sub PGA(colNum As Long, LastRow As Long, foundPass As Range, List As Range)
    Dim People As Integer
    Dim Gift As Integer
    Dim PeopleRange As String
    Dim GiftRange As String
    Dim List2 As Range
    Dim AgeRange As String


    For Each List In Range(Cells(3, colNum + 14), Cells(LastRow, colNum + 14))
        People = Mid(List.Value, 1, 1)
        Select Case People
            Case 1
                PeopleRange = "1 Person"
            Case 2
                PeopleRange = "2 People"
            Case 3
                PeopleRange = "3 People"
            Case 4
                PeopleRange = "4 People"
            Case 5
                PeopleRange = "5 People"
            Case Is >= 6
                PeopleRange = "6+ People"

        End Select
        Gift = Mid(List.Value, 5, 1)
        Select Case Gift
           Case 1
                GiftRange = "1 Gift"
            Case 2
                GiftRange = "2 Gifts"
            Case 3
                GiftRange = "3 Gifts"
            Case 4
                GiftRange = "4 Gifts"
            Case 5
                GiftRange = "5 Gifts"
            Case Is >= 6
                GiftRange = "6+ Gifts"
        End Select
        For Each List2 In Range(Cells(3, colNum + 15), Cells(LastRow, colNum + 15))
            List2.Value = AgeRange
            List.Offset(0, 20).Value = PeopleRange & "/" & GiftRange & "/" & AgeRange
        Next List2
    Next List

End Sub

0 个答案:

没有答案