Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 360
Default need relative cells instead of hard coded

This macro works except it leaves off the top row header. I added the code
at the end that hard codes in the first row. The first row is labels so I
start at the 2nd row. In the last piece
it adds the value in cell (2,17) which is the department name to (3,4)
because since I added a blank row header it is now on the 3rd line. The
problem is I need to use this in a loop so I need it to calculate the row it
is on instead of it being hard coded.
So where it says
..rows(2). insert
it needs to be relative using the irow variable.

Thanks, this is urgent!

-----
sDeptID = .Cells(iRow, 16)
sNextDeptID = .Cells(iRow + 1, 16)
'first if block creates the Item Name headers


If .Cells(iRow, 16).Value = .Cells(iRow - 1, 16).Value Then
' if the department is the same as previous
'create the status headers


Else
'if the department is a new department add the row header
sDeptName = .Cells(iRow, 17).Value
.Rows(iRow).Insert
.Range(.Cells(iRow, 1), .Cells(iRow, 26)).Interior.ColorIndex = 15
.Cells(iRow, 3).Value = sDeptName

.Cells(iRow, 3).Font.Bold = True
.Cells(iRow, 3).Font.Size = 14
.Cells(iRow, 3).RowHeight = 18
End If
Next iRow

..Rows(2).Insert
'.Range(.Cells(2, 1), .Cells(2, 26)).Interior.ColorIndex = 15
ActiveSheet.Rows(2).Interior.ColorIndex = 15
..Range(.Cells(2, 1), .Cells(2, 26)).Interior.ColorIndex = 15

With .Cells(2, 3)

.Value = "" & .Cells(3, 17)
.Font.Bold = True
.Font.Size = 14
.RowHeight = 18

End With

End With
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default need relative cells instead of hard coded

Haven't checked through the whole code, but maybe

..rows(iRow + 1). insert

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Janis" wrote in message
...
This macro works except it leaves off the top row header. I added the

code
at the end that hard codes in the first row. The first row is labels so I
start at the 2nd row. In the last piece
it adds the value in cell (2,17) which is the department name to (3,4)
because since I added a blank row header it is now on the 3rd line. The
problem is I need to use this in a loop so I need it to calculate the row

it
is on instead of it being hard coded.
So where it says
.rows(2). insert
it needs to be relative using the irow variable.

Thanks, this is urgent!

-----
sDeptID = .Cells(iRow, 16)
sNextDeptID = .Cells(iRow + 1, 16)
'first if block creates the Item Name headers


If .Cells(iRow, 16).Value = .Cells(iRow - 1, 16).Value Then
' if the department is the same as previous
'create the status headers


Else
'if the department is a new department add the row header
sDeptName = .Cells(iRow, 17).Value
.Rows(iRow).Insert
.Range(.Cells(iRow, 1), .Cells(iRow, 26)).Interior.ColorIndex = 15
.Cells(iRow, 3).Value = sDeptName

.Cells(iRow, 3).Font.Bold = True
.Cells(iRow, 3).Font.Size = 14
.Cells(iRow, 3).RowHeight = 18
End If
Next iRow

.Rows(2).Insert
'.Range(.Cells(2, 1), .Cells(2, 26)).Interior.ColorIndex = 15
ActiveSheet.Rows(2).Interior.ColorIndex = 15
.Range(.Cells(2, 1), .Cells(2, 26)).Interior.ColorIndex = 15

With .Cells(2, 3)

.Value = "" & .Cells(3, 17)
.Font.Bold = True
.Font.Size = 14
.RowHeight = 18

End With

End With
End Sub



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
Combo Box / Hard Coded List trip_to_tokyo[_3_] Excel Discussion (Misc queries) 1 January 2nd 10 11:31 AM
do the same thing to multiple hard coded cells Sam Excel Worksheet Functions 3 March 7th 08 11:07 PM
hard coded text William Benson[_2_] Excel Programming 2 July 6th 05 06:40 PM
Index Sheet which summarizes all cells with hard coded data. ExcelMonkey[_161_] Excel Programming 1 December 1st 04 05:53 PM
Find Hard Coded Cells Steph[_3_] Excel Programming 3 November 7th 04 04:18 PM


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