Do While True "Select" problem.
Dim cell as Range, rng as Range
for each cell in worksheets("CodeGrid").Range("A1:A75")
if cell.Value = Worksheets("Coding" _
).Range("A1").Value Then
set rng = cell
exit for
end if
next
if not rng is nothing then
msgbox "found match as " & rng.Address(0,0,xlA1,True)
Else
msgbox "Not found"
End if
or
Dim tgt, rng1 as Range, res, rng as Range
set rng1 = worksheets("CodeGrid").Range("A1:A75")
tgt = Worksheets("Coding" _
).Range("A1").Value
res = Application.Match(tgt,rng1,0)
if not iserror(res) then
set rng = rng1(1,res)
msgbox "found match as " & rng.Address(0,0,xlA1,True)
else
msgbox "Not found"
end if
--
Regards,
Tom Ogilvy
"Shawn" wrote:
Below is my code. I want to be able to do this without having to Select
anything on the CodeGrid Sheet. When I select I am having to unlock the
workbook. Is there a way I can do this without having to "select"?
ActiveWorkbook.Unprotect Password:="Time"
Worksheets("CodeGrid").Visible = True
Worksheets("CodeGrid").Activate
Range("A1").Select
Do While True And ActiveCell.Column < 75
If Worksheets("Coding").Range("A1").Value = _
ActiveCell.Value Then
Exit Do
End If
ActiveCell.Offset(0, 1).Select
Loop
ActiveCell.EntireColumn.Select
Selection.Copy Destination:=Sheets("Password").Range("L1")
--
Thanks
Shawn
|