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: 360
Default help on looping structures

This is a database spreadsheet with the first row as the field headers.
I need to get the first Division number and then keep comparing it with the
other division numbers until I hit the next one. If it is the first mention
then I need to insert a gray header row. Can you help me with the loop?


Public Sub ColorRowHeaders()
'GREY ROW HEADER FOR FIRST ROW OF A DEPARTMENT IN A DIVISION
'Database is sorted on Division Number, Department Number and status
'Create row header in light gray above the first row
'of each consecutive Department in a Division
'cell 0 = division #
'cell P = division name
'cell Q = department #
'cell R = department name

' Create a medium grey row header above first row of every status type
within a department

'Cell Q1 status column ,Take Down, Continue, or Replace
'put a pagebreak at the end of every division

Dim lrow As Long
Dim rng As Range
Dim prevDivsion# As Integer
Dim Division# As Integer
lrow = 2
Set rng = Range("A&lrow")
With rng


Do While lrow < .Cells(Rows.Count, "A").End(xlUp)
Division# = .Cells("0 &lrow")
If .Cells("0 &lrow ").Value < prevDivision
Insert Row
Selection.Interior.ColorIndex = Gray
Header:= .cells(" Department name (cell,P &lrow)


lrow = lrow + 1
End while
End Sub


thanks,
 
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
How do I draw chemical structures in Excel spreed sheet? James Charts and Charting in Excel 1 March 31st 09 08:29 AM
Using VS 2003 .NET structures in VBA application Wayne Clements Excel Programming 0 March 27th 06 01:18 AM
Importing File Structures to Excel asummers Excel Discussion (Misc queries) 3 February 23rd 06 01:42 PM
If...then structures HeyMickey Excel Programming 5 September 14th 05 01:20 AM
Useing Class structures and Events Dan Gardner Excel Programming 2 January 13th 05 08:43 AM


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