View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
struggler struggler is offline
external usenet poster
 
Posts: 3
Default VBA searching through range and pasting value if no match is found

Hi im trying to complete my function, but i struggle! please help:

Public Function Generate_GetNum()

Dim celle As String
Dim hold As String
Dim frompage As String
Dim topage As String
Dim i As Integer

frompage = "Generert dokumentliste"
topage = "Produktliste"

For i = 2 To 20000 ' Aktiverer celle
celle = Worksheets(frompage).Cells(i, 2)
If celle = "" Then
Exit For

Else
celle = Worksheets(frompage).Cells(i, 2)
hold = Mid(celle, 10, 5)

Worksheets(topage).Cells(i + 2, 1) = hold '<-- should be replaced
' Now it just pastes and does no search. here i want to search for value
"hold" in Worksheets(topage).Cells(4, 1) and search stops down where first
cell with no value.
' if value is not found in the search it should be pastet in the first empty
cell who was found.
' if value is found then "next i"



End If
Next i

End Function