How to Add Data To An Array When Column Has Blank Cells

Brad24

Board Regular
Joined
May 4, 2015
Messages
81
Hi, I have names in a column but some cells are empty. I want to grab the first 32 names and put them into an array, but how would I skip over the empty cells? THis is using vba.
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
If you are looping through the range, you just need to qualify each cell before performing the work on it.

If MyCell <> "" then '<<< This qualifys the cell as being a cell which IS NOT Blank

' your code to perform

End if
 
Upvote 0
I have another question: If my data is in rows 1 to 1500, how do I pick off the data and put it in the array sequentially from 0 to 31?
Currently, I am back to my original problem. If there is data on line 400 and 402, then 401 is blank, and the array index will be empty

I have
Code:
For k = 1 To 1500
    If Sheets("Segment Staging").Cells(k, 3).Value <> "" Then
    'Copy the name into the Array
    MyArray() = Sheets("Segment Staging").Cells(k, 3).Value
Next k
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,935
Messages
6,122,337
Members
449,077
Latest member
Jocksteriom

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