Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How do I copy a data from a single column into an array and back into another column?

Hi,

I'm posting this actually as an answer to the question I kept googling
and googling for but couldn't find a straightforward answer for. Maybe
others will reply with a better way to solve this problem.

Anyways, I have data in a single column in one Excel spreadsheet that
I want to extract, process in memory, and insert into another
spreadsheet.

here's the code I used

Dim idArray() As Variant
ReDim idArray(13 to srcRange.Rows.Count,1) 'note that this is a 2d
array even though I only need a single column.

For i = 13 to srcRange.Rows.Count
idArray(i,0) = srcRange.Cells(i,1).Value
Next

'Process array data
.....
'Put data back starting at second cell of first column
Worksheets(1).Range("A2").Resize(UBound(idArray)). Value = idArray

The part that kept vexing me was that idArray needs to be 2
dimensional even though I only need to copy a single column into the
array and back. Hopefully this will keep someone else from going batty
trying to figure this out!

Thanks,
Walter

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How do I copy a data from a single column into an array and back into another column?

some people just use

Worksheets(1).Range("A2").Resize( _
UBound(idArray),1).Value = Application.Transpose(idArray)

to avoid having to have a 2D array.

--
Regards,
Tom Ogilvy

wrote in message
ups.com...
Hi,

I'm posting this actually as an answer to the question I kept googling
and googling for but couldn't find a straightforward answer for. Maybe
others will reply with a better way to solve this problem.

Anyways, I have data in a single column in one Excel spreadsheet that
I want to extract, process in memory, and insert into another
spreadsheet.

here's the code I used

Dim idArray() As Variant
ReDim idArray(13 to srcRange.Rows.Count,1) 'note that this is a 2d
array even though I only need a single column.

For i = 13 to srcRange.Rows.Count
idArray(i,0) = srcRange.Cells(i,1).Value
Next

'Process array data
....
'Put data back starting at second cell of first column
Worksheets(1).Range("A2").Resize(UBound(idArray)). Value = idArray

The part that kept vexing me was that idArray needs to be 2
dimensional even though I only need to copy a single column into the
array and back. Hopefully this will keep someone else from going batty
trying to figure this out!

Thanks,
Walter



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Plotting multiple Y column data versus single X column in Excel 20 RossM Charts and Charting in Excel 3 June 28th 09 01:39 AM
I would like to copy UNIQUE data from a column in a SINGLE CELL Yogi Excel Discussion (Misc queries) 2 July 14th 07 07:20 AM
Converting an array of data into a single column Raj Excel Discussion (Misc queries) 0 August 15th 06 09:21 PM
Copy Excel data content listed in 3 columns into a single column mooorrona Excel Programming 1 January 12th 05 04:14 AM
Coverting array data into single column dgarg Excel Worksheet Functions 4 December 15th 04 07:43 AM


All times are GMT +1. The time now is 05:51 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"