LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Need to Loop some code based on a count of Cells

Hi
I need to loop some formatting Code based on a count of rows at the
beginning, My data starts at A8 and includes columns B and C, But the
number of rows may vary that dat is printed in to. What needs to
happen is that after i have all the data i need to add 2 blank lines
after each line of data and then format the 3 lines (1 x Data and 2 x
Blank) to merge and centre this needs to happen for each line of data.
Below is the code i am using that formats the first line correctly but
i can't automate it to repeat for other lines. PLEASE HELP i am miles
out of my depth, every attempt i make gets me stuck in an infinite
loop

Sheets("CashFlow").Activate
ActiveSheet.Range("9:9").Select
Selection.Insert Shift:=xlDown,
CopyOrigin:=xlFormatFromLeftOrAbove
ActiveSheet.Range("9:9").Select
Selection.Insert Shift:=xlDown,
CopyOrigin:=xlFormatFromLeftOrAbove
ActiveSheet.Range("A8:A10").Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
ActiveSheet.Range("B8:B10").Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
ActiveSheet.Range("C8:C10").Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With

 
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
Count cells based upon criteria in other cells JT Excel Worksheet Functions 14 December 20th 09 09:06 PM
Count of Cells Based on Format Dawg House Inc Excel Discussion (Misc queries) 1 August 15th 07 11:36 PM
Loop through worksheets & empty cells based on color Eugene_Elder Excel Programming 3 March 31st 07 03:06 PM
Count cells based on value in a range bimmerman Excel Discussion (Misc queries) 1 August 9th 06 11:06 PM
A loop to merge cells based on a value tschultz[_3_] Excel Programming 0 August 24th 05 07:50 PM


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