View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Nigel[_2_] Nigel[_2_] is offline
external usenet poster
 
Posts: 735
Default Vlookup finance help please

The following code does what you want, paste the code behind the sheet you
wish to act upon.

Sub FindandSum()
Dim lR As Long
Dim rngF As Range
Dim sInput As String
Dim dblM As Double
Dim dblN As Double
sInput = Trim(InputBox("Enter Reference Number", "Title in Here"))
If Len(sInput) 0 Then
Set rngF = Cells.Find(What:=sInput, _
After:=Range("A1"), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, _
MatchCase:= False, _
SearchFormat:=False)
If Not rngF Is Nothing Then
lR = rngF.Row
Do While sInput = Trim(Cells(lR, "A"))
dblM = dblM + Cells(lR, "M")
dblN = dblN + Cells(lR, "N")
lR = lR + 1
Loop
Cells(lR - 1, "Q") = dblM
Cells(lR - 1, "R") = dblN
End If
End If
End Sub

--

Regards,
Nigel




"Chris" wrote in message
...
Hi Nigel, thanks for replying. The File Reference Numbers are in order.
The File Reference Numbers are entered in in groups.

For example:

I may enter in File Reference Number: FTAN52147 in column A six times if
it relates to travel. So, File Reference Number: FTAN52147 is showing
in range: A196:A201.

Thus, the File Reference Number: FTAN52147 is all bunched together in
order. Overall, the File Reference Numbers may not be in order in
column A.

For example:

File Reference Number: FTAN52148 is in range: A78:A83. However, all
instances of File Reference Number: FTAN52148 are all bunched together.

I hope this makes sense.

Kind regards,

Chris.



*** Sent via Developersdex
http://www.developersdex.com ***