Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Simple (?) Macro Assistance- Select, Insert, Paste, Rinse, Repeat

Hi, hoping someone can help. I need to write a macro that will Selec
cells 6-10 from a row of 20 and insert them below the original line
select cells 11-15 insert below 6-10, select cells 16-20 and inser
below 11-15. Then move down to a new row of data and repeat th
process. It seem so simple, but I am a complete novice

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Simple (?) Macro Assistance- Select, Insert, Paste, Rinse, Repeat

Try record the process you have just describe. Do some prunings and put a loop (For... Next or Do While.... loop) over it. This set of codes would be too tedious to write by hand.

"Pete_CSC " wrote:

Hi, hoping someone can help. I need to write a macro that will Select
cells 6-10 from a row of 20 and insert them below the original line,
select cells 11-15 insert below 6-10, select cells 16-20 and insert
below 11-15. Then move down to a new row of data and repeat the
process. It seem so simple, but I am a complete novice!


---
Message posted from http://www.ExcelForum.com/


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Simple (?) Macro Assistance- Select, Insert, Paste, Rinse, Repeat

Either of these seems to work:

Sub ReorderData()
Dim rng As Range, rng1 As Range
Dim rng2 As Range, rng3 As Range
Set rng = Cells(ActiveCell.Row, 1)
Set rng1 = Cells(ActiveCell.Row, 6).Resize(1, 5)
Set rng2 = rng1.Offset(0, 5)
Set rng3 = rng1.Offset(0, 10)
rng.Offset(1, 0).Resize(3).EntireRow.Insert
rng.Offset(1, 0).Resize(1, 5).Value = rng1.Value
rng.Offset(2, 0).Resize(1, 5).Value = rng2.Value
rng.Offset(3, 0).Resize(1, 5).Value = rng3.Value
End Sub

Sub ReorderData1()
Dim rng As Range, rng1 As Range
Dim rng2 As Range, rng3 As Range
Set rng = Cells(ActiveCell.Row, 1)
rng.Offset(1, 0).Resize(3).EntireRow.Insert
For i = 1 To 3
rng.Offset(i, 0).Resize(1, 5).Value = _
rng.Offset(0, i * 5).Resize(1, 5).Value
Next
End Sub

I am not sure of your starting and stopping conditions, but you could put a
loop around either and have

Sub ReorderData1()
Dim rng As Range, rng1 As Range
Dim rng2 As Range, rng3 As Range
Dim i As Long, j As Long
For j = 1 To 4
Set rng = Cells(ActiveCell.Row, 1)
rng.Offset(1, 0).Resize(3).EntireRow.Insert
For i = 1 To 3
rng.Offset(i, 0).Resize(1, 5).Value = _
rng.Offset(0, i * 5).Resize(1, 5).Value
Next i
ActiveCell.Offset(4, 0).Select
Next j
End Sub

as an example to do 4 existing rows.

--
Regards,
Tom Ogilvy

"Pete_CSC " wrote in message
...
Hi, hoping someone can help. I need to write a macro that will Select
cells 6-10 from a row of 20 and insert them below the original line,
select cells 11-15 insert below 6-10, select cells 16-20 and insert
below 11-15. Then move down to a new row of data and repeat the
process. It seem so simple, but I am a complete novice!


---
Message posted from http://www.ExcelForum.com/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Simple (?) Macro Assistance- Select, Insert, Paste, Rinse, Repeat

Hi Tom, thank you very much for your Macro; it is very close to what
need. How do I tell it to start at row 16 and repeat 200 times instea
of 4

--
Message posted from http://www.ExcelForum.com

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Simple (?) Macro Assistance- Select, Insert, Paste, Rinse, Repeat

Sub AAReorderData1()
Dim rng As Range, rng1 As Range
Dim rng2 As Range, rng3 As Range
Dim i As Long, j As Long
For j = 16 To 816 Step 4
Set rng = Cells(j, 1)
rng.Offset(1, 0).Resize(3).EntireRow.Insert
For i = 1 To 3
rng.Offset(i, 0).Resize(1, 5).Value = _
rng.Offset(0, i * 5).Resize(1, 5).Value
Next i
Next j
End Sub


--
Regards,
Tom Ogilvy


"Pete_CSC " wrote in message
...
Hi Tom, thank you very much for your Macro; it is very close to what I
need. How do I tell it to start at row 16 and repeat 200 times instead
of 4?


---
Message posted from http://www.ExcelForum.com/



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 Macro - I think... Copy - Paste on Click Scott Campbell[_2_] Excel Discussion (Misc queries) 5 November 14th 12 12:52 AM
Select dynamic data in 2 columns, and repeat macro to next sheet Tasha Excel Discussion (Misc queries) 2 September 17th 09 07:00 PM
Macro that will select and insert a new row and paste as value [email protected] Excel Worksheet Functions 3 December 5th 06 04:06 AM
How to write a simple copy-paste macro? R. H. Rosenberg New Users to Excel 4 November 25th 06 12:26 AM
Help please on a simple macro to insert rows Michelle Curtin Excel Programming 1 October 3rd 03 05:20 PM


All times are GMT +1. The time now is 11:11 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"