Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Simple question

I have a worksheet "Orderform" containing a range B8:B12 and a variable
number of rows starting A17:D17, A18:D18, etc.

I need to copy this data over to another sheet "Orders" in a different
workbook such that the range B8:B12 is transposed and pasted at the
beginning of each row and the end of each row is a straight copy from
"Orderform". So it ends up like this:

B8 B9 B10 B11 B12 A17 B17 C17 D17
B8 B9 B10 B11 B12 A18 B18 C18 D18
B8 B9 B10 B11 B12 A19 B19 C19 D19
etc

I've written a macro to do this (see below) but it seems a bit messy.
I'm new to this and sure there's a more efficient way of doing it. In
particular I'm thinking there must be a way to combine the vertical and
horizontal ranges and pasting in one go rather than doing it in two
chunks as I have...any advice much appreciated


Workbooks("order.xls").Sheets("Orderform").Activat e
Dim rw As Long
rw = 17

Do Until ActiveSheet.Cells(rw, 1) = ""

Range(Cells(8, 2), Cells(12, 2)).Select
Application.CutCopyMode = False
Selection.Copy

Workbooks("master.xls").Sheets("Orders").Activate
Range("A1").End(xlDown).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats,
Operation:= _
xlNone, SkipBlanks:=False, Transpose:=True

Workbooks("order.xls").Sheets("Orderform").Activat e
Range(Cells(rw, 1), Cells(rw, 4)).Select
Application.CutCopyMode = False
Selection.Copy

Workbooks("master.xls").Sheets("Orders").Activate
Range("F1").End(xlDown).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats,
Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False

Workbooks("order.xls").Sheets("Orderform").Activat e

rw = rw + 1

Loop

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Simple question

Do Until ActiveSheet.Cells(rw, 1) = ""

Fyi, Cells always refers to the active sheet

Range(Cells(8, 2), Cells(12, 2)).Select


You do not have to select a range to copy it or paste to it.

Application.CutCopyMode = False


You do not have to clear the clipboard before using it.

So...

Range(Cells(8, 2), Cells(12, 2)).Copy
Workbooks("master.xls").Sheets("Orders").Range("A1 ").End(xlDown).Offset(1).PasteSpecial
Paste:=xlPasteValuesAndNumberFormats, Operation:= xlNone, SkipBlanks:=False,
Transpose:=True


--
Jim
wrote in message
ps.com...
|I have a worksheet "Orderform" containing a range B8:B12 and a variable
| number of rows starting A17:D17, A18:D18, etc.
|
| I need to copy this data over to another sheet "Orders" in a different
| workbook such that the range B8:B12 is transposed and pasted at the
| beginning of each row and the end of each row is a straight copy from
| "Orderform". So it ends up like this:
|
| B8 B9 B10 B11 B12 A17 B17 C17 D17
| B8 B9 B10 B11 B12 A18 B18 C18 D18
| B8 B9 B10 B11 B12 A19 B19 C19 D19
| etc
|
| I've written a macro to do this (see below) but it seems a bit messy.
| I'm new to this and sure there's a more efficient way of doing it. In
| particular I'm thinking there must be a way to combine the vertical and
| horizontal ranges and pasting in one go rather than doing it in two
| chunks as I have...any advice much appreciated
|
|
| Workbooks("order.xls").Sheets("Orderform").Activat e
| Dim rw As Long
| rw = 17
|
| Do Until ActiveSheet.Cells(rw, 1) = ""
|
| Range(Cells(8, 2), Cells(12, 2)).Select
| Application.CutCopyMode = False
| Selection.Copy
|
| Workbooks("master.xls").Sheets("Orders").Activate
| Range("A1").End(xlDown).Offset(1, 0).Select
| Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats,
| Operation:= _
| xlNone, SkipBlanks:=False, Transpose:=True
|
| Workbooks("order.xls").Sheets("Orderform").Activat e
| Range(Cells(rw, 1), Cells(rw, 4)).Select
| Application.CutCopyMode = False
| Selection.Copy
|
| Workbooks("master.xls").Sheets("Orders").Activate
| Range("F1").End(xlDown).Offset(1, 0).Select
| Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats,
| Operation:= _
| xlNone, SkipBlanks:=False, Transpose:=False
|
| Workbooks("order.xls").Sheets("Orderform").Activat e
|
| rw = rw + 1
|
| Loop
|


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
simple sum question smiley61799 New Users to Excel 1 April 21st 09 04:58 PM
IF formula-simple question; simple operator Rich D Excel Discussion (Misc queries) 4 December 6th 07 03:36 PM
Simple Simple Excel usage question BookerW Excel Discussion (Misc queries) 1 June 23rd 05 10:06 PM
simple question, hopefully a simple answer! Matt B Excel Programming 5 January 13th 04 08:43 PM
Simple question No Name Excel Programming 1 November 25th 03 12:16 PM


All times are GMT +1. The time now is 04:00 PM.

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"