Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
JMJ JMJ is offline
external usenet poster
 
Posts: 11
Default Name groups of .offset ranges

Hello everyone,
I'm a bit stuck and I would really appreciate your help.

Using Worksheet_Change, I am formatting rows depending on a value in a cell.

Offset works perfect. But I have recurrent formatting instances, with
different combination and I don't know how to name the blocks of ".offset"
instructions to be able to use them without re-writing the same blocks over
and over again.
Thanks in advance for any light you may give me!

This is a sample of the code I'm using:
------------------------

Private Sub Worksheet_Change(ByVal target As Range)
If Not Application.Intersect(target, Range("F10,F12,F14")) Is Nothing Then
With target
Select Case .Value
Case "First":
.Offset(0, 7).Resize(1, 1).Cells.ClearContents
.Offset(0, -5).Resize(1, 4).Interior.ColorIndex = xlNone
.Offset(0, -1).Resize(1, 7).Interior.ColorIndex = 35


Case "Second":

.Offset(0, 7).Resize(1, 1).Value = "OK"
.Offset(0, -2).Resize(1, 21).Interior.ColorIndex = 40
.Offset(0, -3).Resize(1, 3).Cells.Locked = True

End Select
End With
End If
End sub
---------------
Regards,


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default Name groups of .offset ranges

Perhaps you could Call a Sub routine from your Select Case statement:
Case "First"
Call First
Case "Second"
Call Second

Sub First ()
.Offset(0, 7).Resize(1, 1).Cells.ClearContents
.Offset(0, -5).Resize(1, 4).Interior.ColorIndex = xlNone
.Offset(0, -1).Resize(1, 7).Interior.ColorIndex = 35
End Sub
Sub Second ()
.Offset(0, 7).Resize(1, 1).Value = "OK"
.Offset(0, -2).Resize(1, 21).Interior.ColorIndex =
40
.Offset(0, -3).Resize(1, 3).Cells.Locked = True
End Sub

This is just an idea, not the actual code. You would need a Public variable
to pass the range of Target to the called routine.

Mike F
"JMJ" wrote in message
...
Hello everyone,
I'm a bit stuck and I would really appreciate your help.

Using Worksheet_Change, I am formatting rows depending on a value in a
cell.

Offset works perfect. But I have recurrent formatting instances, with
different combination and I don't know how to name the blocks of ".offset"
instructions to be able to use them without re-writing the same blocks
over
and over again.
Thanks in advance for any light you may give me!

This is a sample of the code I'm using:
------------------------

Private Sub Worksheet_Change(ByVal target As Range)
If Not Application.Intersect(target, Range("F10,F12,F14")) Is Nothing Then
With target
Select Case .Value
Case "First":
.Offset(0, 7).Resize(1, 1).Cells.ClearContents
.Offset(0, -5).Resize(1, 4).Interior.ColorIndex =
xlNone
.Offset(0, -1).Resize(1, 7).Interior.ColorIndex = 35


Case "Second":

.Offset(0, 7).Resize(1, 1).Value = "OK"
.Offset(0, -2).Resize(1, 21).Interior.ColorIndex =
40
.Offset(0, -3).Resize(1, 3).Cells.Locked = True

End Select
End With
End If
End sub
---------------
Regards,




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
Dynamic Ranges and Offset RFJ Excel Worksheet Functions 3 August 29th 06 03:20 PM
How do I calculate an offset between two ranges? mo childs Excel Programming 4 October 19th 05 11:27 AM
Using Offset with named ranges StanJ Excel Worksheet Functions 5 September 2nd 05 09:07 AM
OFFSET function to pick up monthly groups of data Gary T Excel Worksheet Functions 2 January 14th 05 02:13 PM
Ranges using offset Fatir Zelen Excel Programming 11 April 24th 04 11:15 PM


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