View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
[email protected] scott@lacksweb.com is offline
external usenet poster
 
Posts: 5
Default ActiveX comboboxes on worksheet (lost focus problems)

Here is the code in the FindData procedu

Public Sub FindData()

Application.Cursor = xlWait

Application.ScreenUpdating = False

Sheet8.Unprotect

Range("clearrange").Clear
Range("newhirepersarea").Value = code

'code = ComboBox1.Value

Thanks in advance!!!!!!!!

Worksheets("PersAreaMaster").Activate
[a2].Select

Do While ActiveCell < code
ActiveCell.Offset(1, 0).Select
Loop

rowCount = 0
PersCodeCount = 0
test = True

Do While ActiveCell = code

PersCodeCount = PersCodeCount + 1

If test = True Then
'FIND FIRST ROW OF CURRENT RANGE
firstRow = ActiveCell.Row
test = False
End If
rowCount = rowCount + 1
ActiveCell.Offset(1, 0).Select
Loop



ActiveCell.Offset(-1, 0).Select
lastRow = ActiveCell.Row

For L = 0 To 6


Set AllCells = Range("" & Chr(65 + L) & firstRow & ":" & Chr(65 +
L) & lastRow & "")

On Error Resume Next
For Each Cell In AllCells
NoDupes.Add Cell.Value, CStr(Cell.Value)

Next Cell

On Error GoTo 0

For i = 1 To NoDupes.Count - 1
For j = i + 1 To NoDupes.Count
If NoDupes(i) NoDupes(j) Then
Swap1 = NoDupes(i)
Swap2 = NoDupes(j)
NoDupes.Add Swap1, befo=j
NoDupes.Add Swap2, befo=i
NoDupes.Remove i + 1
NoDupes.Remove j + 1
End If
Next j
Next i

Range("clearrange").NumberFormat = "@"

Worksheets("dynrange").Activate
Range("" & Chr(65 + L) & "2").Select
For Each Item In NoDupes
ActiveCell = Item
ActiveCell.Offset(1, 0).Select
Next Item

For k = NoDupes.Count To 1 Step -1
NoDupes.Remove (k)
Next

Worksheets("PersAreaMaster").Activate


Next

ActiveCell.Offset(-(PersCodeCount - 1), 7).Select
Range(Selection, ActiveCell.Offset(0, 1)).Select
Range(Selection, ActiveCell.Offset((PersCodeCount - 1), 0)).Select
Selection.Copy
Worksheets("dynrange").Activate
[h2].Select
ActiveSheet.Paste
Application.CutCopyMode = False
Application.CutCopyMode = False

Worksheets("PersAreaMaster").Activate
Range("a" & lastRow).Select
ActiveCell.Offset(-(PersCodeCount - 1), 9).Select
Range(Selection, ActiveCell.Offset(0, 2)).Select
Range(Selection, ActiveCell.Offset((PersCodeCount - 1), 0)).Select
Selection.Copy
Worksheets("dynrange").Activate
[j2].Select
ActiveSheet.Paste
Application.CutCopyMode = False
Application.CutCopyMode = False

Worksheets("Requisition & Workflow").Activate

Sheet8.Protect

Application.ScreenUpdating = True

Application.Cursor = xlDefault

End Sub