How to skip one column in an Array

288enzo

Well-known Member
Joined
Feb 8, 2009
Messages
723
Office Version
  1. 2016
Platform
  1. Windows
I'm trying to skip one column in my array.
Below where I have "Skip" is the column I want to skip. It would be the 7th column or B11.

VBA Code:
    var = Array("ABE", "ACE", "ILT", "IND", "TOP", "TOP2", Skip, "ADD")
    Set rng = Range("B4")
    For i = 0 To UBound(var)
    rng.Offset(0, i + 1) = "=IFERROR(ROUNDDOWN(COUNTIFS(SUBAREA,RIGHT(A4,3),DEPT," & MYDEPT & "," & var(i) & ",""Y"")/COUNTIFS(SUBAREA,RIGHT(A4,3),DEPT," & MYDEPT & "," & var(i) & ",""<>N/A""),2),""N/A"")"
    Next i
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
There area lot of different ways to do that. One way:

VBA Code:
    Var = Array("ABE", "ACE", "ILT", "IND", "TOP", "TOP2", "Skip", "ADD")
    Set Rng = Range("B4")
    For i = 0 To UBound(Var)
        Select Case i
            Case 6    'skip
            Case Else
                Rng.Offset(0, i + 1) = "=IFERROR(ROUNDDOWN(COUNTIFS(SUBAREA,RIGHT(A4,3),DEPT," & MYDEPT & "," & Var(i) & ",""Y"")/COUNTIFS(SUBAREA,RIGHT(A4,3),DEPT," & MYDEPT & "," & Var(i) & ",""<>N/A""),2),""N/A"")"
        End Select
    Next i
 
Upvote 0
Solution
There area lot of different ways to do that. One way:

VBA Code:
    Var = Array("ABE", "ACE", "ILT", "IND", "TOP", "TOP2", "Skip", "ADD")
    Set Rng = Range("B4")
    For i = 0 To UBound(Var)
        Select Case i
            Case 6    'skip
            Case Else
                Rng.Offset(0, i + 1) = "=IFERROR(ROUNDDOWN(COUNTIFS(SUBAREA,RIGHT(A4,3),DEPT," & MYDEPT & "," & Var(i) & ",""Y"")/COUNTIFS(SUBAREA,RIGHT(A4,3),DEPT," & MYDEPT & "," & Var(i) & ",""<>N/A""),2),""N/A"")"
        End Select
    Next i
Worked perfectly, thank you for the help.
 
Upvote 0

Forum statistics

Threads
1,215,500
Messages
6,125,166
Members
449,210
Latest member
grifaz

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top