![]() |
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 |
All times are GMT +1. The time now is 05:15 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com