Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88075

Is an array inside a select case statement possible?

$
0
0

I just want to know if it is possible for me to assign an array and use it as a qualifier inside a case statement?

Sub AccountCopy()
Dim Criteria1 As Variant
Dim Criteria2 As Variant
Dim Acct As Variant
Dim NR As Integer

Criteria1 = Array("Checking", "Savings")
Criteria2 = Array("Loans", "Credit Card")

MonthSheet.Range("T1") = "Title"
MonthSheet.Range("U1") = "Account"
MonthSheet.Range("V1") = "Description"
MonthSheet.Range("W1") = "Amount"
MonthSheet.Range("X1") = "Date"
MonthSheet.Range("Y1") = "Category"

With Range("T1:Y1")
    .Font.Name = "Calibri"
    .Font.Size = 8
    .Font.Bold = True
    .HorizontalAlignment = xlCenter
    .Style = "Title"
    .Columns.AutoFit
End With



For Each Acct In [AccountNameList]
    Select Case Acct.Offset(0, 1).Value
        Case Is = Criteria1
            NR = Range("T"& Rows.Count).End(xlUp).Row + 1 'Next Row
            'MonthSheet.Range 
        Case Criteria2
    End Select

Don't criticize me too hard, I'm still pretty new to this. I don't post on fourms very often, but their are some really talented people on here and I thought who better to ask then the people that have been coding for years? Thanks in advance!

This is what I want to accomplish: I want to define the "Criteria1" Array to how ever many dimensions I so desire. Perhaps I want to add a third criteria to the list. Rather than going and changing the case statement, I would rather just add to the array later on down the line to include that additional qualifier. Perhaps I've set the wrong type? I don't know? I feel like this can be done rather easy but I am missing a very small detail.


Viewing all articles
Browse latest Browse all 88075

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>