D
davegb
The following code hangs at the marked line:
Set wsCtyLst = Workbooks("Mark Top 10.xls").Worksheets("CtyLst")
Set wsSrc = ActiveSheet
Set rCtyLst = wsCtyLst.Range("C2:C11")
'wsCtyLst.Activate
'rCtyLst.Select
sCtyCol = InputBox("Please enter the column where the counties are
currently listed", _
, "A")
sColMrk10 = InputBox("Please enter the column to mark the Top Ten
Counties")
'sCtyLstCol = "C"
'TEST for valid entries on both variables
'TEST sColMrk10 for existing data
' TEST for county numbers/names or names
Set rCty = wsSrc.Cells(2, sCtyCol).End(xlDown) '<---ERROR
wsSrc.Activate
rCty.Select
Set rFndCell = Cells.Find(What:=rCty, _
After:=ActiveCell, _
LookIn:=xlValues, _
LookAt:=xlPart, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, _
MatchCase:=False)
Select Case rFndCell
Case "ADAMS"
lRow = wsCtyLst.Cells(2, sCtyLstCol).End(xlDown)
Set rCtyLst = wsCtyLst.Range(.Cells(2, sCtyLstCol), _
.Cells(lRow, sCtyLstCol)) <--ERROR
' wsCtyLst.Activate
' rCtyLst.Select
Case "01-ADAMS"
MsgBox "oops!"
End Select
For Each rCell In rCtyLst
wsSrc.Activate
Set rFndCell = Cells.Find(What:=rCell, _
After:=ActiveCell, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not rFndCell Is Nothing Then
Set rCtyMrkr = wsSrc.Cells(rFndCell.Row, sColMrk10)
rCtyMrkr = "y"
End If
Next
Application.ScreenUpdating = True
End Sub
Defining a range by cells defined by variable names never seems to
work, no matter how many ways I try to get it or how many lines of code
I look at in other examples. Any ideas?
Set wsCtyLst = Workbooks("Mark Top 10.xls").Worksheets("CtyLst")
Set wsSrc = ActiveSheet
Set rCtyLst = wsCtyLst.Range("C2:C11")
'wsCtyLst.Activate
'rCtyLst.Select
sCtyCol = InputBox("Please enter the column where the counties are
currently listed", _
, "A")
sColMrk10 = InputBox("Please enter the column to mark the Top Ten
Counties")
'sCtyLstCol = "C"
'TEST for valid entries on both variables
'TEST sColMrk10 for existing data
' TEST for county numbers/names or names
Set rCty = wsSrc.Cells(2, sCtyCol).End(xlDown) '<---ERROR
wsSrc.Activate
rCty.Select
Set rFndCell = Cells.Find(What:=rCty, _
After:=ActiveCell, _
LookIn:=xlValues, _
LookAt:=xlPart, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, _
MatchCase:=False)
Select Case rFndCell
Case "ADAMS"
lRow = wsCtyLst.Cells(2, sCtyLstCol).End(xlDown)
Set rCtyLst = wsCtyLst.Range(.Cells(2, sCtyLstCol), _
.Cells(lRow, sCtyLstCol)) <--ERROR
' wsCtyLst.Activate
' rCtyLst.Select
Case "01-ADAMS"
MsgBox "oops!"
End Select
For Each rCell In rCtyLst
wsSrc.Activate
Set rFndCell = Cells.Find(What:=rCell, _
After:=ActiveCell, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not rFndCell Is Nothing Then
Set rCtyMrkr = wsSrc.Cells(rFndCell.Row, sColMrk10)
rCtyMrkr = "y"
End If
Next
Application.ScreenUpdating = True
End Sub
Defining a range by cells defined by variable names never seems to
work, no matter how many ways I try to get it or how many lines of code
I look at in other examples. Any ideas?