View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
JRForm JRForm is offline
external usenet poster
 
Posts: 130
Default Help with search and create code

Mekinnik,

Here try it with this code.

= dept Then


Sub Mekinnik()

Dim iLastRow As Long
Dim look4Me As String
look4Me = Me.CboDept.Value
iLastRow = Range("H" & Range("H:H").Rows.Count).End(xlUp).Row
'change to the column you want to search

Range("H1").Select 'go to the top of the column to begin searching

Do Until iLastRow = -1

If ActiveCell = look4Me Then
dept = Me.CboDept.Value & 0 + 1
Else

End If

iLastRow = iLastRow - 1
ActiveCell.Offset(1, 0).Select
Loop

End Sub

"Mekinnik" wrote:

I am trying to create an alphanumeric value and insert it into a sheet column
'M' based on a combocox selection, I want it to search column 'M' find the
left 2 letters then add 1 number to the value it creates. I have been trying
to create it but keep failing, here is my code

'searches for duplicate MSDS# in column 'M'
dept = Columns(13).Find(What:=CboDept.Value, _
After:=Cells(5000, 13), LookIn:=xlFormulas, _
LookAT:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False, _
SearchFormat:=False).Row
If Me.CboDept.Value = "" Then
End If
If Me.CboDept.Value = dept Then
dept = Me.CboDept.Value & 0 + 1
End If
Exit Sub