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: 9
Default Code to reference offset cells - NCAA

Hello again,

Thanks in advance for any help I might get. If you are familiar with NCAA
basketball brackets, you'll have a good

understanding of what I am trying to accomplish with the following.

Private Sub Worksheet_SelectionChange(ByVal target As Range)
If target.Column = 13 Then
With ActiveCell
.Offset([-1], [-1]) = [b2]
.Offset([1], [-1]) = [af2]
End With
Else
If target.Column = 14 Then
With ActiveCell
.Offset([-2], [-1]) = [b2]
.Offset([2], [-1]) = [af2]
End With
Else
If target.Column = 15 Then
With ActiveCell
.Offset([-4],[-1] = [b2]
.Offset([4],[-1]= [af2]
End With
End If
End If
End If
End Sub

I need to populate cell [B2] with a team name and cell [AF2] with an
opposing team name. For example, in cell [M9]of

last years bracket, a selection between Illinois[L8] and Fairleigh Dickinson
[L10] needed to be made. This year I

will be using data validation to provide a drop down box in [M9] giving me
the the only two options (Illinois and

F-D). Upon activating cell [M9], I would like to populate cell [B2] with
"Illinois" and cell [AF2] with "F-D". I

will then use the data in these two cells to look up team statistics for
review while I am making my selection.

But I can't get the code to work. I am very new to VB and am trying to use
these silly projects to learn.

The following code seems to work for populating cell [B2] but crashes when
I try to simultaneously populate cell

[AF2]:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column = 13 Then
[b2] = ActiveCell.Offset([-1], [-1])
Else
If Target.Column = 14 Then
[b2] = ActiveCell.Offset([-2], [-1])
Else
If Target.Column = 15 Then
[b2] = ActiveCell.Offset([-4], [-1])
End If
End If
End If
End Sub

Based on what have read here, this should be simple for many here, but I am
not one.

Thanks again
 
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
ComboBox AddItem code to reference cells in a Range HBC_MT Excel Discussion (Misc queries) 0 February 26th 09 04:05 PM
offset reference shashidhar Excel Worksheet Functions 1 March 23rd 08 09:33 PM
NCAA 2007 NCAA Bracket and Tracker [email protected] Excel Discussion (Misc queries) 8 March 13th 07 02:34 AM
Using an offset formula for the reference in a relative reference Cuda Excel Worksheet Functions 6 November 15th 06 05:12 PM
Problem with Range.Cells.Offset and Range.Cells( row + offset, column) [email protected] Excel Programming 2 August 22nd 05 05:25 AM


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