Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Graying Out Some Rows

Hi,
I never did Excel programming before, but I do VB
programming. I have a spreadsheet with many rows and
columns, to make it more easy to read the data in each
row, I was wondering if there is a way to program the
spreadsheet the way that every other row is grayed out.
Please help and please tell me how to access Excel modules
to type in the code.
Thanks a million.
Tamer
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Graying Out Some Rows

Tamer,

Do the following:

1) Press ALT+F11 to open the VBA Editor.
2) There, go to the Insert menu and choose module.
3) In the Module, paste the following code

Sub ColorRows()
Dim RowNdx As Long
For RowNdx = 1 To ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastC ell).Row
_
Step 2
Rows(RowNdx).Interior.ColorIndex = 15
Next RowNdx
End Sub

4) Flip back to Excel
5) Pres ALT+F8 to display the Macro dialog
6) Choose ColorRows and click Run.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com





"Tamer Seoud" wrote in message
...
Hi,
I never did Excel programming before, but I do VB
programming. I have a spreadsheet with many rows and
columns, to make it more easy to read the data in each
row, I was wondering if there is a way to program the
spreadsheet the way that every other row is grayed out.
Please help and please tell me how to access Excel modules
to type in the code.
Thanks a million.
Tamer



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Graying Out Some Rows

You can do this with conditional formatting
formatconditional formatttingcond 1select formula istype in
=mod(row(),2)=0 and format as desiredcopy to other cells or select cells
first

--
Don Guillett
SalesAid Software

"Tamer Seoud" wrote in message
...
Hi,
I never did Excel programming before, but I do VB
programming. I have a spreadsheet with many rows and
columns, to make it more easy to read the data in each
row, I was wondering if there is a way to program the
spreadsheet the way that every other row is grayed out.
Please help and please tell me how to access Excel modules
to type in the code.
Thanks a million.
Tamer



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Graying Out Some Rows

Chip,
Thanks for your reply. I tried what you told me but I get
an error message "Syntax Error". Am I supposed to paste
the exact code you sent me or I have to change something
on it? And What is the "_" in the code between the first
part and Step 2? It seems there is a problem with the "_".
Please advise. Thanks again for your help.

Tamer

-----Original Message-----
Tamer,

Do the following:

1) Press ALT+F11 to open the VBA Editor.
2) There, go to the Insert menu and choose module.
3) In the Module, paste the following code

Sub ColorRows()
Dim RowNdx As Long
For RowNdx = 1 To ActiveSheet.UsedRange.SpecialCells

(xlCellTypeLastCell).Row
_
Step 2
Rows(RowNdx).Interior.ColorIndex = 15
Next RowNdx
End Sub

4) Flip back to Excel
5) Pres ALT+F8 to display the Macro dialog
6) Choose ColorRows and click Run.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com





"Tamer Seoud" wrote

in message
...
Hi,
I never did Excel programming before, but I do VB
programming. I have a spreadsheet with many rows and
columns, to make it more easy to read the data in each
row, I was wondering if there is a way to program the
spreadsheet the way that every other row is grayed out.
Please help and please tell me how to access Excel

modules
to type in the code.
Thanks a million.
Tamer



.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Graying Out Some Rows

Tamer,

The lines got split in the posted message.

Try

For RowNdx = 1 To ActiveSheet.UsedRange.SpecialCells _
(xlCellTypeLastCell).Row Step 2

The " _" character is a line continuation character that lets you write one
logical line of code on two actual lines of text.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Tamer Seoud" wrote in message
...
Chip,
Thanks for your reply. I tried what you told me but I get
an error message "Syntax Error". Am I supposed to paste
the exact code you sent me or I have to change something
on it? And What is the "_" in the code between the first
part and Step 2? It seems there is a problem with the "_".
Please advise. Thanks again for your help.

Tamer

-----Original Message-----
Tamer,

Do the following:

1) Press ALT+F11 to open the VBA Editor.
2) There, go to the Insert menu and choose module.
3) In the Module, paste the following code

Sub ColorRows()
Dim RowNdx As Long
For RowNdx = 1 To ActiveSheet.UsedRange.SpecialCells

(xlCellTypeLastCell).Row
_
Step 2
Rows(RowNdx).Interior.ColorIndex = 15
Next RowNdx
End Sub

4) Flip back to Excel
5) Pres ALT+F8 to display the Macro dialog
6) Choose ColorRows and click Run.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com





"Tamer Seoud" wrote

in message
...
Hi,
I never did Excel programming before, but I do VB
programming. I have a spreadsheet with many rows and
columns, to make it more easy to read the data in each
row, I was wondering if there is a way to program the
spreadsheet the way that every other row is grayed out.
Please help and please tell me how to access Excel

modules
to type in the code.
Thanks a million.
Tamer



.





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Graying Out Some Rows

Chip,
You're the man. It worked. Thank you so much.

-----Original Message-----
Tamer,

The lines got split in the posted message.

Try

For RowNdx = 1 To ActiveSheet.UsedRange.SpecialCells _
(xlCellTypeLastCell).Row Step 2

The " _" character is a line continuation character that

lets you write one
logical line of code on two actual lines of text.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Tamer Seoud" wrote

in message
...
Chip,
Thanks for your reply. I tried what you told me but I

get
an error message "Syntax Error". Am I supposed to paste
the exact code you sent me or I have to change something
on it? And What is the "_" in the code between the first
part and Step 2? It seems there is a problem with

the "_".
Please advise. Thanks again for your help.

Tamer

-----Original Message-----
Tamer,

Do the following:

1) Press ALT+F11 to open the VBA Editor.
2) There, go to the Insert menu and choose module.
3) In the Module, paste the following code

Sub ColorRows()
Dim RowNdx As Long
For RowNdx = 1 To ActiveSheet.UsedRange.SpecialCells

(xlCellTypeLastCell).Row
_
Step 2
Rows(RowNdx).Interior.ColorIndex = 15
Next RowNdx
End Sub

4) Flip back to Excel
5) Pres ALT+F8 to display the Macro dialog
6) Choose ColorRows and click Run.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com





"Tamer Seoud"

wrote
in message
...
Hi,
I never did Excel programming before, but I do VB
programming. I have a spreadsheet with many rows and
columns, to make it more easy to read the data in

each
row, I was wondering if there is a way to program the
spreadsheet the way that every other row is grayed

out.
Please help and please tell me how to access Excel

modules
to type in the code.
Thanks a million.
Tamer


.



.

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
Enabling option „Format rows“ to hide/unhide rows using VBA-code? ran58 Excel Discussion (Misc queries) 0 July 28th 09 03:46 PM
Counting characters in multiple rows when rows meet specific criteria news.virginmedia.com Excel Worksheet Functions 3 June 28th 08 09:03 PM
Copy rows of data (eliminating blank rows) from fixed layout Sweepea Excel Discussion (Misc queries) 1 March 13th 07 11:05 PM
Excel 2003 -Rows hidden. Scrolling unhides rows ! How do I stop th Excellent1975 Excel Discussion (Misc queries) 0 June 21st 06 08:01 PM
Charts graying out Mickey Charts and Charting in Excel 2 June 5th 06 09:50 PM


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