LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default How can I modify my code to offset the defined range and repeat the procedure instead of duplicating my code?

1. Do you want to move the ckRng exactly two rows on each iteration?

2. And for how many rows? (i.e. What is the final row to check?)

wrote in message
...
Happy Friday Excel Community! I could really use some help with this.
I have the following code but I want it to offset and repeat the
srcRng for different ranges. I pretty much need this sub procedure to
be repeated for

ckRng("F4:Y4"), ckRng("F6:Y6"), ckRng("F8:Y8"), etc. How can I do
this? Offset the range? Add another loop? I tried a couple things but
it didn't work! Thanks a bunch for any help!

Sub colorMe()
Dim srcRng As Range, ckRng As Range, Clr As Range
Set srcRng = ActiveSheet.Range("C64:C67")
Set ckRng = ActiveSheet.Range("F4:Y4")

Ship1 = Worksheets("Sheet1").Range("C64").Value
Ship2 = Worksheets("Sheet1").Range("C65").Value
Ship3 = Worksheets("Sheet1").Range("C66").Value
Ship4 = Worksheets("Sheet1").Range("C67").Value


For Each c In ckRng
Set Clr = srcRng.Find(c.Value, LookIn:=xlValues)
If Not Clr Is Nothing Then
Select Case Clr.Value

Case Ship1
c.Offset(-1, 0).Interior.ColorIndex = 0
Case Ship2
c.Offset(-1, 0).Interior.ColorIndex = 7
Case Ship3
c.Offset(-1, 0).Interior.ColorIndex = 6
Case Ship4
c.Offset(-1, 0).Interior.ColorIndex = 8



End Select
End If
Next
End Sub



 
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
Dynamic Range & Offset code problem JoAnn Excel Programming 3 September 30th 08 06:08 PM
Modify existing code to dynamic code Ixtreme Excel Programming 5 August 31st 07 11:42 AM
Need code to replace part of a range within a formula with a defined name Jeff[_50_] Excel Programming 2 May 2nd 06 10:59 PM
How to repeat a code for selected sheets (or a contiguous range of sheets) in a Workbook? Dmitry Excel Programming 6 March 29th 06 12:43 PM
Dynamic Range Offset causing problem with this code Arishy[_2_] Excel Programming 1 August 3rd 05 06:15 PM


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