onechipshot
New Member
- Joined
- Jun 9, 2017
- Messages
- 4
The following code is part of a much larger piece and does a very simple task. It does what I want except fails to create the range name "TargetR"
Based on self support the problem is probably in identifying the workbook and sheet. Please help.
Private Sub AAATest()
Dim WS As Worksheet
Dim CellName As String
Dim cell As Range
Dim RangeName As String
Dim myCell As Range
Set WS = ThisWorkbook.Worksheets("Sheet1")
Worksheets("Sheet1").Select
Set myCell = Range(ActiveCell.Address)
RangeName = "TargetR"
CellName = myCell.Offset(0, 1).Address
Set cell = Range(CellName)
ThisWorkbook.Names.Add Name:=RangeName, RefersTo:=cell
End Sub
Based on self support the problem is probably in identifying the workbook and sheet. Please help.
Private Sub AAATest()
Dim WS As Worksheet
Dim CellName As String
Dim cell As Range
Dim RangeName As String
Dim myCell As Range
Set WS = ThisWorkbook.Worksheets("Sheet1")
Worksheets("Sheet1").Select
Set myCell = Range(ActiveCell.Address)
RangeName = "TargetR"
CellName = myCell.Offset(0, 1).Address
Set cell = Range(CellName)
ThisWorkbook.Names.Add Name:=RangeName, RefersTo:=cell
End Sub