Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Write select columns to array & back to another spreadsheet

Hello,

I am trying to take data from select columns in a spreadsheet adn write it
to another spreadsheet. The ciolumns are not aligned in any order, and the
number of rows is unknown from week to week.

For example, I need to take columns: A, B, E, F , j, k, L, copy to array,
and the number of rows is unknown. I then to to spit each column back into
another spreadsheet in a specified column.

I have been reading two books, but it seems they only give examples of
arrays with a known number of rows.

Any help is greatly appreciated. I have been playing with this for days.


Pete


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Write select columns to array & back to another spreadsheet

Why are you puting the data into an aray

CopyColumns = Array("A", "B", "E", "F", "j", "k", "L")
FirstRow = 2
With Sheets("Sheet1")
For Each col In CopyColumns
LastRow = .Range(col & Rows.Count).End(xlUp).Row
.Range(col & FirstRow & ":" & col & LastRow).Copy
With Sheets("Sheet2")
LastRow = .Range(col & Rows.Count).End(xlUp).Row
NewRow = LastRow + 1
.Range("A" & NewRow).Paste
End With
Next col
End With

"petedacook" wrote:

Hello,

I am trying to take data from select columns in a spreadsheet adn write it
to another spreadsheet. The ciolumns are not aligned in any order, and the
number of rows is unknown from week to week.

For example, I need to take columns: A, B, E, F , j, k, L, copy to array,
and the number of rows is unknown. I then to to spit each column back into
another spreadsheet in a specified column.

I have been reading two books, but it seems they only give examples of
arrays with a known number of rows.

Any help is greatly appreciated. I have been playing with this for days.


Pete


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Write select columns to array & back to another spreadsheet

I figured if I copied the data I would have to write each column to the
destination before copying the next column. I figred if i write the columns
to 1 or more arrays I could write the array all at once, then write all at
one.

Is that not correct?

Thanks, Joel.
Pete


"Joel" wrote:

Why are you puting the data into an aray

CopyColumns = Array("A", "B", "E", "F", "j", "k", "L")
FirstRow = 2
With Sheets("Sheet1")
For Each col In CopyColumns
LastRow = .Range(col & Rows.Count).End(xlUp).Row
.Range(col & FirstRow & ":" & col & LastRow).Copy
With Sheets("Sheet2")
LastRow = .Range(col & Rows.Count).End(xlUp).Row
NewRow = LastRow + 1
.Range("A" & NewRow).Paste
End With
Next col
End With

"petedacook" wrote:

Hello,

I am trying to take data from select columns in a spreadsheet adn write it
to another spreadsheet. The ciolumns are not aligned in any order, and the
number of rows is unknown from week to week.

For example, I need to take columns: A, B, E, F , j, k, L, copy to array,
and the number of rows is unknown. I then to to spit each column back into
another spreadsheet in a specified column.

I have been reading two books, but it seems they only give examples of
arrays with a known number of rows.

Any help is greatly appreciated. I have been playing with this for days.


Pete


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Write select columns to array & back to another spreadsheet

The code can be much simpler than you have shown. These two lines should do
what your code does...

Const Cols2Copy As String = "A:A,B:B,E:E,F:F,J:J,K:K,L:L"
Worksheets("Sheet1").Range(Cols2Copy).Copy Worksheets("Sheet2").Range("A1")

Notice the format that the columns are specified in.

--
Rick (MVP - Excel)


"petedacook" wrote in message
...
I figured if I copied the data I would have to write each column to the
destination before copying the next column. I figred if i write the
columns
to 1 or more arrays I could write the array all at once, then write all at
one.

Is that not correct?

Thanks, Joel.
Pete


"Joel" wrote:

Why are you puting the data into an aray

CopyColumns = Array("A", "B", "E", "F", "j", "k", "L")
FirstRow = 2
With Sheets("Sheet1")
For Each col In CopyColumns
LastRow = .Range(col & Rows.Count).End(xlUp).Row
.Range(col & FirstRow & ":" & col & LastRow).Copy
With Sheets("Sheet2")
LastRow = .Range(col & Rows.Count).End(xlUp).Row
NewRow = LastRow + 1
.Range("A" & NewRow).Paste
End With
Next col
End With

"petedacook" wrote:

Hello,

I am trying to take data from select columns in a spreadsheet adn write
it
to another spreadsheet. The ciolumns are not aligned in any order, and
the
number of rows is unknown from week to week.

For example, I need to take columns: A, B, E, F , j, k, L, copy to
array,
and the number of rows is unknown. I then to to spit each column back
into
another spreadsheet in a specified column.

I have been reading two books, but it seems they only give examples of
arrays with a known number of rows.

Any help is greatly appreciated. I have been playing with this for
days.


Pete



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Write select columns to array & back to another spreadsheet

Rick: Your code won't put the results into one column. Your results will end
up in multiple columns

Pete: It is not easy to append one aray onto another array. You will need a
loop. It is more efficent to just copy from worksheet to workwsheet instead
of going through an intermediate aray.

"Rick Rothstein" wrote:

The code can be much simpler than you have shown. These two lines should do
what your code does...

Const Cols2Copy As String = "A:A,B:B,E:E,F:F,J:J,K:K,L:L"
Worksheets("Sheet1").Range(Cols2Copy).Copy Worksheets("Sheet2").Range("A1")

Notice the format that the columns are specified in.

--
Rick (MVP - Excel)


"petedacook" wrote in message
...
I figured if I copied the data I would have to write each column to the
destination before copying the next column. I figred if i write the
columns
to 1 or more arrays I could write the array all at once, then write all at
one.

Is that not correct?

Thanks, Joel.
Pete


"Joel" wrote:

Why are you puting the data into an aray

CopyColumns = Array("A", "B", "E", "F", "j", "k", "L")
FirstRow = 2
With Sheets("Sheet1")
For Each col In CopyColumns
LastRow = .Range(col & Rows.Count).End(xlUp).Row
.Range(col & FirstRow & ":" & col & LastRow).Copy
With Sheets("Sheet2")
LastRow = .Range(col & Rows.Count).End(xlUp).Row
NewRow = LastRow + 1
.Range("A" & NewRow).Paste
End With
Next col
End With

"petedacook" wrote:

Hello,

I am trying to take data from select columns in a spreadsheet adn write
it
to another spreadsheet. The ciolumns are not aligned in any order, and
the
number of rows is unknown from week to week.

For example, I need to take columns: A, B, E, F , j, k, L, copy to
array,
and the number of rows is unknown. I then to to spit each column back
into
another spreadsheet in a specified column.

I have been reading two books, but it seems they only give examples of
arrays with a known number of rows.

Any help is greatly appreciated. I have been playing with this for
days.


Pete






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Write select columns to array & back to another spreadsheet

Ah, yes, I see I missed the "in a specified column" part of the OP's
original post.

--
Rick (MVP - Excel)


"Joel" wrote in message
...
Rick: Your code won't put the results into one column. Your results will
end
up in multiple columns

Pete: It is not easy to append one aray onto another array. You will need
a
loop. It is more efficent to just copy from worksheet to workwsheet
instead
of going through an intermediate aray.

"Rick Rothstein" wrote:

The code can be much simpler than you have shown. These two lines should
do
what your code does...

Const Cols2Copy As String = "A:A,B:B,E:E,F:F,J:J,K:K,L:L"
Worksheets("Sheet1").Range(Cols2Copy).Copy
Worksheets("Sheet2").Range("A1")

Notice the format that the columns are specified in.

--
Rick (MVP - Excel)


"petedacook" wrote in message
...
I figured if I copied the data I would have to write each column to the
destination before copying the next column. I figred if i write the
columns
to 1 or more arrays I could write the array all at once, then write all
at
one.

Is that not correct?

Thanks, Joel.
Pete


"Joel" wrote:

Why are you puting the data into an aray

CopyColumns = Array("A", "B", "E", "F", "j", "k", "L")
FirstRow = 2
With Sheets("Sheet1")
For Each col In CopyColumns
LastRow = .Range(col & Rows.Count).End(xlUp).Row
.Range(col & FirstRow & ":" & col & LastRow).Copy
With Sheets("Sheet2")
LastRow = .Range(col & Rows.Count).End(xlUp).Row
NewRow = LastRow + 1
.Range("A" & NewRow).Paste
End With
Next col
End With

"petedacook" wrote:

Hello,

I am trying to take data from select columns in a spreadsheet adn
write
it
to another spreadsheet. The ciolumns are not aligned in any order,
and
the
number of rows is unknown from week to week.

For example, I need to take columns: A, B, E, F , j, k, L, copy to
array,
and the number of rows is unknown. I then to to spit each column
back
into
another spreadsheet in a specified column.

I have been reading two books, but it seems they only give examples
of
arrays with a known number of rows.

Any help is greatly appreciated. I have been playing with this for
days.


Pete





  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Write select columns to array & back to another spreadsheet

Joel,

I think you answered my question. I thought it would be faster to write the
data to an array, then spit it out. Rather than copy/paste one column at a
time.

I think there may be a misunderstanding and I apologize for not being more
clrea. The column that is copied may not go into the corresponding column on
the other sheet. Column A data may go in column B on the destination sheet.

I will work on the copy paste method.

Thanks again,

Pete









"Joel" wrote:

Rick: Your code won't put the results into one column. Your results will end
up in multiple columns

Pete: It is not easy to append one aray onto another array. You will need a
loop. It is more efficent to just copy from worksheet to workwsheet instead
of going through an intermediate aray.

"Rick Rothstein" wrote:

The code can be much simpler than you have shown. These two lines should do
what your code does...

Const Cols2Copy As String = "A:A,B:B,E:E,F:F,J:J,K:K,L:L"
Worksheets("Sheet1").Range(Cols2Copy).Copy Worksheets("Sheet2").Range("A1")

Notice the format that the columns are specified in.

--
Rick (MVP - Excel)


"petedacook" wrote in message
...
I figured if I copied the data I would have to write each column to the
destination before copying the next column. I figred if i write the
columns
to 1 or more arrays I could write the array all at once, then write all at
one.

Is that not correct?

Thanks, Joel.
Pete


"Joel" wrote:

Why are you puting the data into an aray

CopyColumns = Array("A", "B", "E", "F", "j", "k", "L")
FirstRow = 2
With Sheets("Sheet1")
For Each col In CopyColumns
LastRow = .Range(col & Rows.Count).End(xlUp).Row
.Range(col & FirstRow & ":" & col & LastRow).Copy
With Sheets("Sheet2")
LastRow = .Range(col & Rows.Count).End(xlUp).Row
NewRow = LastRow + 1
.Range("A" & NewRow).Paste
End With
Next col
End With

"petedacook" wrote:

Hello,

I am trying to take data from select columns in a spreadsheet adn write
it
to another spreadsheet. The ciolumns are not aligned in any order, and
the
number of rows is unknown from week to week.

For example, I need to take columns: A, B, E, F , j, k, L, copy to
array,
and the number of rows is unknown. I then to to spit each column back
into
another spreadsheet in a specified column.

I have been reading two books, but it seems they only give examples of
arrays with a known number of rows.

Any help is greatly appreciated. I have been playing with this for
days.


Pete




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
Write data back from a form to sheet Steen Excel Discussion (Misc queries) 9 October 22nd 08 01:22 PM
How can I write 3/5 in a cell and have it look like 03-May back? Janneman Excel Discussion (Misc queries) 4 May 28th 08 01:23 PM
Reading back a Read/Write Property Gary''s Student Excel Programming 2 November 18th 07 10:06 AM
Load text file and write back sanjay Excel Programming 1 May 26th 04 03:28 AM
How to write back a SQL Server table from Excel Belinda Excel Programming 3 February 16th 04 12:41 PM


All times are GMT +1. The time now is 10:33 AM.

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

About Us

"It's about Microsoft Excel"