#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 46
Default variable ranges

Hi
I have Change event macro that sorts a table in G3:O6 when a value in F3:F6
is changed. What I need to happen is that if the range of the entered data is
F13:F18 the table sorted changes to G13:O16. I have been trying to vary the
values in the €˜If Not Intersect(Target, Range("F13:F18")) Then statemnt but
without success. Any help would be appreciated.
Al

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,522
Default variable ranges

As ALWAYS, post your code for comments or

If desired, send your file to my address below. I will only look if:
1. You send a copy of this message on an inserted sheet
2. You give me the newsgroup and the subject line
3. You send a clear explanation of what you want
4. You send before/after examples and expected results.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"gramps" wrote in message
...
Hi
I have Change event macro that sorts a table in G3:O6 when a value in
F3:F6
is changed. What I need to happen is that if the range of the entered data
is
F13:F18 the table sorted changes to G13:O16. I have been trying to vary
the
values in the €˜If Not Intersect(Target, Range("F13:F18")) Then statemnt
but
without success. Any help would be appreciated.
Al


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default variable ranges

post your code
--
HTH...

Jim Thomlinson


"gramps" wrote:

Hi
I have Change event macro that sorts a table in G3:O6 when a value in F3:F6
is changed. What I need to happen is that if the range of the entered data is
F13:F18 the table sorted changes to G13:O16. I have been trying to vary the
values in the €˜If Not Intersect(Target, Range("F13:F18")) Then statemnt but
without success. Any help would be appreciated.
Al

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 46
Default variable ranges

Thanks guys code as below works as far as it goes:-
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column < 6 Then Exit Sub
gcol = 7: ncol = 14: ocol = 15: lcol = 12
If Not Intersect(Target, Range("F3:F8")) Then
grow = 3: orow = 6
Range(Cells(grow, gcol), Cells(orow, ocol)).Select
ActiveWorkbook.Worksheets("Sheet1").Sort.SortField s.Clear
Worksheets("Sheet1").Sort.SortFields.Add Key:=Range(Cells(grow, ncol),
Cells(orow, ncol)), _
SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
Worksheets("Sheet1").Sort.SortFields.Add Key:=Range(Cells(grow, ocol),
Cells(orow, ocol)), _
SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
Worksheets("Sheet1").Sort.SortFields.Add Key:=Range(Cells(grow, lcol),
Cells(orow, lcol)), _
SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").Sort
.SetRange Range(Cells(grow, gcol), Cells(orow, ocol))
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End If
End Sub
This sorts a soccer league table of 4 teams in a round robin event (G3:G6)
1st by points then goal difference then by goals scored, when match results
are entered into E3:F8 (column F is the event trigger). What I want to be
able to do is to extend this to a 2nd group of matches where the results are
entered into F13:F18 and the table is (G13:G18) and depending on the range of
cells the match results are entered the correct table is sorted. I hope
that all makes sense and would thank you in advance for any help you can give.
Al


"Jim Thomlinson" wrote:

post your code
--
HTH...

Jim Thomlinson


"gramps" wrote:

Hi
I have Change event macro that sorts a table in G3:O6 when a value in F3:F6
is changed. What I need to happen is that if the range of the entered data is
F13:F18 the table sorted changes to G13:O16. I have been trying to vary the
values in the €˜If Not Intersect(Target, Range("F13:F18")) Then statemnt but
without success. Any help would be appreciated.
Al

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,522
Default variable ranges


You could use select case to input variables into your sort. I repeat my
offer
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"gramps" wrote in message
...
Thanks guys code as below works as far as it goes:-
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column < 6 Then Exit Sub
gcol = 7: ncol = 14: ocol = 15: lcol = 12
If Not Intersect(Target, Range("F3:F8")) Then
grow = 3: orow = 6
Range(Cells(grow, gcol), Cells(orow, ocol)).Select
ActiveWorkbook.Worksheets("Sheet1").Sort.SortField s.Clear
Worksheets("Sheet1").Sort.SortFields.Add Key:=Range(Cells(grow, ncol),
Cells(orow, ncol)), _
SortOn:=xlSortOnValues, Order:=xlDescending,
DataOption:=xlSortNormal
Worksheets("Sheet1").Sort.SortFields.Add Key:=Range(Cells(grow, ocol),
Cells(orow, ocol)), _
SortOn:=xlSortOnValues, Order:=xlDescending,
DataOption:=xlSortNormal
Worksheets("Sheet1").Sort.SortFields.Add Key:=Range(Cells(grow, lcol),
Cells(orow, lcol)), _
SortOn:=xlSortOnValues, Order:=xlDescending,
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").Sort
.SetRange Range(Cells(grow, gcol), Cells(orow, ocol))
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End If
End Sub
This sorts a soccer league table of 4 teams in a round robin event (G3:G6)
1st by points then goal difference then by goals scored, when match
results
are entered into E3:F8 (column F is the event trigger). What I want to be
able to do is to extend this to a 2nd group of matches where the results
are
entered into F13:F18 and the table is (G13:G18) and depending on the range
of
cells the match results are entered the correct table is sorted. I hope
that all makes sense and would thank you in advance for any help you can
give.
Al


"Jim Thomlinson" wrote:

post your code
--
HTH...

Jim Thomlinson


"gramps" wrote:

Hi
I have Change event macro that sorts a table in G3:O6 when a value in
F3:F6
is changed. What I need to happen is that if the range of the entered
data is
F13:F18 the table sorted changes to G13:O16. I have been trying to vary
the
values in the €˜If Not Intersect(Target, Range("F13:F18")) Then
statemnt but
without success. Any help would be appreciated.
Al




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
Help with Variable Ranges! Nelson B. Excel Discussion (Misc queries) 1 August 21st 08 03:30 PM
Variable Ranges Erika Excel Worksheet Functions 1 November 30th 07 09:21 PM
variable reference ranges SC Excel Discussion (Misc queries) 2 September 14th 07 05:18 AM
Variable ranges John Contact Excel Worksheet Functions 1 June 17th 05 08:02 AM
Sum Variable Ranges Erika Excel Worksheet Functions 6 December 23rd 04 03:52 PM


All times are GMT +1. The time now is 04:33 AM.

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"