Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Vlookup finance help please

Hello, could someone please help me with the following:

In my worksheet (Named: Register) I need a Vlookup macro that asks the
user for a File Reference Number (via Input Box).

All the File Reference Numbers are in column A.

I need Vlookup to lookup columns M and N and sum all the values that are
associated with the User's File Reference Number, and then place the sum
in columns Q and R respectively - adjacent to the last User entered File
Reference Number in column A.

Example: Column A contains 5-references to the User entered File
Reference Number (Cells A8:A12), I need Vlookup to sum the values in
(Cells M8: M12) and places this figure into cell Q12. Also I need
Vlookup to sum the values in (cells N8:N12) and place this figure into
cell R12.

Any help would be greatly appreciated,

Kind regards,

Chris.



*** Sent via Developersdex http://www.developersdex.com ***
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Vlookup finance help please

Hi Don, thanks for you help - just having difficulties getting your code
to do what I need it to do.

Sub sumifem()
myval = InputBox("Enter acct num")
lr = Cells(Rows.Count, "a").End(xlUp).Row
Range("d1").Value = Application. _
SumIf(Range("a2:a" & lr), myval, Range("b2:b" & lr))
End Sub

I think the difficulty is in the the following area of your code:

Range("d1").Value = Application. _
SumIf(Range("a2:a" & lr), myval, Range("b2:b" & lr))

I need it to sum the values in columns M and N respectively and then
place that summed values in to columns Q and R, adjacent to the last
User entered File Reference Number.

Example: if the File Reference Number in column A was: ABC123 and there
were 5 instances of this same number, then I need Excel to sum up all
the values that exist in columns M and N for this File Reference Number.
Just by way of explanation, let us assume that File Reference Number:
ABC123 is located in cells: A8:A12. I would then need Excel to sum up
the corresponding values in cells: M8:M12 and N8:N12 respectively. The
sum of cells: M8:M12 needs to be placed in cell: Q12. The sum of cells:
N8:N12 needs to be placed in cell R12.

I hope this helps explain what I am attempting to achieve.

If you could provide further assistance, that would be very much
appreciated.

kind regards,

Chris.

*** Sent via Developersdex http://www.developersdex.com ***
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Vlookup finance help please

Hi Nigel, thanks for you help. Please note that I do not wish to use
auto-filtering for this particular request.

Here is an example: if the File Reference Number in column A was: ABC123
and there
were 5 instances of this same number, then I need Excel to sum up all
the values that exist in columns M and N for this File Reference Number.
Just by way of explanation, let us assume that File Reference Number:
ABC123 is located in cells: A8:A12. I would then need Excel to sum up
the corresponding values in cells: M8:M12 and N8:N12 respectively. The
sum of cells: M8:M12 needs to be placed in cell: Q12. The sum of cells:
N8:N12 needs to be placed in cell R12.

I hope this helps explain what I am attempting to achieve.

If you could provide further assistance, that would be very much
appreciated.

kind regards,

Chris.




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


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default Vlookup finance help please

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 ***
  #8   Report Post  
Posted to microsoft.public.excel.programming
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 ***

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Vlookup finance help please

Sub evaluatesumproduct()
myval = InputBox("Enter acct num")
Range("d1").Value = Application. _
Evaluate("=SUMPRODUCT((A2:A7=" & myval & ")*M2:N7)")
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Chris Hankin" wrote in message
...
Hi Don, thanks for you help - just having difficulties getting your code
to do what I need it to do.

Sub sumifem()
myval = InputBox("Enter acct num")
lr = Cells(Rows.Count, "a").End(xlUp).Row
Range("d1").Value = Application. _
SumIf(Range("a2:a" & lr), myval, Range("b2:b" & lr))
End Sub

I think the difficulty is in the the following area of your code:

Range("d1").Value = Application. _
SumIf(Range("a2:a" & lr), myval, Range("b2:b" & lr))

I need it to sum the values in columns M and N respectively and then
place that summed values in to columns Q and R, adjacent to the last
User entered File Reference Number.

Example: if the File Reference Number in column A was: ABC123 and there
were 5 instances of this same number, then I need Excel to sum up all
the values that exist in columns M and N for this File Reference Number.
Just by way of explanation, let us assume that File Reference Number:
ABC123 is located in cells: A8:A12. I would then need Excel to sum up
the corresponding values in cells: M8:M12 and N8:N12 respectively. The
sum of cells: M8:M12 needs to be placed in cell: Q12. The sum of cells:
N8:N12 needs to be placed in cell R12.

I hope this helps explain what I am attempting to achieve.

If you could provide further assistance, that would be very much
appreciated.

kind regards,

Chris.

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

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default Vlookup finance help please

Hi Nigel, thanks so much for the code - greatly appreciated. It does
work if I use numbers only for the File Reference Number in column A.
When I enter text such as "FTAN52147" it does not work for some reason.
Could you please modify your code so that it works for string data?

Thanks,

Chris.



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


  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default Vlookup finance help please

Hi Don, thanks for your reply, but unfortunately your VBA code does not
seem to work at all. Nigel provided me with the following code below:

It works well if the File Reference Number is a number. However, I need
the File Reference Number to be text (example: FTAN52147).

Any further assistance that you or Nigel can give me would be very much
appreciated.

Kind regards,

Chris.

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



*** Sent via Developersdex http://www.developersdex.com ***
  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 735
Default Vlookup finance help please

It does work for both numeric's and strings, however you must have spaces at
the end of your string entries, these are part of the reference. Find will
look for an exact match including spaces.

Either remove the trailing spaces from your reference code, or the procedure
will need to be changed



--

Regards,
Nigel




"Chris" wrote in message
...
Hi Nigel, thanks so much for the code - greatly appreciated. It does
work if I use numbers only for the File Reference Number in column A.
When I enter text such as "FTAN52147" it does not work for some reason.
Could you please modify your code so that it works for string data?

Thanks,

Chris.



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

  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default Vlookup finance help please

Hi Nigel,

I removed all the spaces from the File Reference Numbers and then your
code worked well. Thanks again for your help,

Cheers,

Chris.



*** Sent via Developersdex http://www.developersdex.com ***
  #14   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Vlookup finance help please

This works for col A with your text and cols M:N with your numbers

Sub evaluatesumproductString1()
Dim myval, colm, coln
myval = InputBox("Enter acct num")
'myval = Range("b1")
colm = Application. _
SumIf(Range("A2:A22"), myval, Range("M2:m22"))
coln = Application. _
SumIf(Range("A2:A22"), myval, Range("n2:N22"))
Range("d1") = colm + coln
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Chris" wrote in message
...
Hi Don, thanks for your reply, but unfortunately your VBA code does not
seem to work at all. Nigel provided me with the following code below:

It works well if the File Reference Number is a number. However, I need
the File Reference Number to be text (example: FTAN52147).

Any further assistance that you or Nigel can give me would be very much
appreciated.

Kind regards,

Chris.

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



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

  #15   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default Vlookup finance help please


Thanks Don for all your excellent help - greatly appreciated.

kind regards,

Chris.


*** Sent via Developersdex http://www.developersdex.com ***
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Google finance David Excel Programming 7 February 3rd 09 04:35 AM
finance functions not available Ivanl Excel Worksheet Functions 8 July 24th 07 08:06 PM
Excel and Finance erikhs[_9_] Excel Programming 2 May 23rd 06 02:16 PM
Finance Formula Help JCH Excel Worksheet Functions 3 April 10th 06 04:45 PM
finance functions Star Excel Programming 0 December 15th 05 07:47 AM


All times are GMT +1. The time now is 06:56 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"