Return middle column of data using array

confusion123

Active Member
Joined
Jul 27, 2014
Messages
400
I have 3 columns of data.

Code:
MyArray() = Cells(1,1)

would return all three columns.

but I only want the middle column.

Is there a quick way of doing that, instead of creating another array and looping?

Thanks

EDIT SORTED:

Code:
Application.WorksheetFunction.Index(Myarray, 0, 2)
 
Last edited:

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Hi,
Did I correclty understand, that you have in cells(1,1) something like "afdsa(separator)hgfds(separator)fdafds"
if yes, what the separator is?
 
Upvote 0
I have data, say in columns 1 to 3 and I just want to retrieve the values in column 2.

Code:
Dim MyArray() As Variant

MyArray = Cells(1,1).CurrentRegion.Value

Dim MiddleArray() As Variant

MiddleArray = Application.WorksheetFunction.Index(MyArray, 0, 2)
 
Upvote 0
As i don`t know what exactly is your data. I`d guess, that you need:
1. read file
2. take 2 column from it
3. place it in column B.

the second item can be done in such way:
if you have a symbol CR (carriage return), then just read it line by line.
in each line you have some separator between columns (i guess it is space). read from 1 space to 2 space in each line.
if you get more detailes I could help you with VBA macro

Sergej.

OR
use text to col, get 2 col.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,534
Messages
6,120,080
Members
448,943
Latest member
sharmarick

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