Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Esrei
 
Posts: n/a
Default Macro to coppy cells to certain rows depending on value in cell

I want his macro to after it have inserted the colmns and added the formula to
1. copy range A1 to E1 to every row where the word "Header" is in colmn F.
2. Then copy paste the whole sheet as values.
3. Then the range now standing left of "header" must be copied to the empy
cells beneath each heading.

For example

a b c d e
f
1)12/12/2005 F001 SAO3 1 CCE Header
2)
Detail
3)13/05/2005 A001 SAO4 2 CCI Header
4)
Detail
5)
Detail

Range A1:E1 must be coppied to A2:E2 but range A3:E3 must be coppied to A4:E5
and so on.

I am trying to write a database export in a readble sortable way.

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 09/12/2005 by Nadia
'

'
Columns("A:E").Select
Selection.Insert Shift:=xlToRight
Range("A1").Select
ActiveCell.FormulaR1C1 = "=RC[6]"
Range("B1").Select
ActiveCell.FormulaR1C1 = "=RC[8]"
Range("C1").Select
ActiveCell.FormulaR1C1 = "=RC[8]"
Range("D1").Select
ActiveCell.FormulaR1C1 = "=RC[8]"
Range("E1").Select
ActiveCell.FormulaR1C1 = "=RC[8]"
Range("A2").Select
Dim LastRow As Long
Dim row_index As Long
Application.ScreenUpdating = False
LastRow = ActiveSheet.Cells(Rows.Count, "F").End(xlUp).Row
For row_index = LastRow - 1 To 2 Step -1
If Cells(row_index, "F").Value = "Header" Then
Rows(1).Copy Destination:=Rows(row_index + 1)
End If
Next


Thanks

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
checking that cells have a value before the workbook will close kcdonaldson Excel Worksheet Functions 8 December 5th 05 04:57 PM
Macro Help In Excel welshlad Excel Discussion (Misc queries) 14 October 26th 05 02:34 PM
macro to hide rows if cell is blank Shooter Excel Worksheet Functions 3 September 28th 05 10:55 PM
Unprotect Cells depending on Cell value Abes Excel Worksheet Functions 2 August 24th 05 10:03 AM
Relative Cell position NOT working with or without macro Scratching my Head Excel Discussion (Misc queries) 6 May 30th 05 06:12 PM


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