User inputs a named range in B112 and presses the "Go" button:
Option Explicit
Sub GetRegion()
'ben Van Johnson, excel help forum http://www.excelforum.com/
'16 january 2011
Application.ScreenUpdating = False
Dim RngName As Range, _
EastWest As String, _
EstWstColumn As Long, _
NorSouth As String, _
NorSthRow As Long, _
CellInfo As Variant
Set RngName = Range("B112")
'get the main e/w and n/s block coords
EastWest = Left(RngName, 3)
NorSouth = Right(RngName, 3)
'---------------clear ALL interior colors
Cells.Select
Range("B1").Activate
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
'----------------------------------------
'move to row with e/w coords to start the "find" op
Range("B115").Select
With Cells
'find the e/w block address and copy the column number
Set CellInfo = .Find(What:=EastWest, _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False)
EstWstColumn = CellInfo.Column
'find the n/s block address and copy the row number
Set CellInfo = .Find(What:=NorSouth, After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False)
NorSthRow = CellInfo.Row
End With
'go to the cell at the intersection of the row and column, resize to six-by=six and color them yellow
Cells(NorSthRow, EstWstColumn).Select
Selection.Resize(6, 6).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Application.ScreenUpdating = True
End Sub
Bookmarks