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: 3
Default Last row, last column revisited

Hi,

I have created a table in Excel. To make it easier to read, I need something that changes the cell color every sixth row from column A to J. I want the VBA subroutine to find the last column in a row that has data. What I have below works. However, I want to subroutine to skip to every sixth row, starting with cell A2 until the last row with data. What I have below works, but I don’t want to hard code the 272 (the last row on this particular table). I want the subroutine to continue to that row and stop. I have tried several suggestions made to the newsgroup, but the routines stop at 266 or goes on an infinite loop. Can you recommend some changes?









Private Sub ColorEverySixthRow()



ActiveSheet.Range("A2").Select



' Dimension variables

Dim lastCOL As Long

Dim lastROW As Long



'Initiate variables

lastROW = 2

lastCOL = Sheets("Sheet1").Range("IV1").End(xlToLeft).Offset (0, 1).Column



'Do Until lastROW = 272



For lastROW = 2 To 272 Step 6

With ActiveSheet

.Range(.Cells(lastROW, 1), .Cells(lastROW, lastCOL - 1)).Interior.ColorIndex = 15

End With

Next



End Sub





I have xl2000 on a windows 98 box.



Thanks.



danz98



 
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
14 Day Average REVISITED F. Lawrence Kulchar Excel Discussion (Misc queries) 4 September 8th 08 11:54 PM
Help with averages revisited TimJames Excel Worksheet Functions 6 March 10th 08 12:20 PM
Blank cell revisited Ross Excel Discussion (Misc queries) 1 September 17th 05 11:59 PM
TextBox formatting (Revisited) ToddG[_2_] Excel Programming 10 April 9th 04 06:34 PM
Revisited: If Cell in row has data then do this: HELP Yogi_Bear_79 Excel Programming 4 February 4th 04 04:49 PM


All times are GMT +1. The time now is 05:25 PM.

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"