Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default Need help editing the Function...

I got the function below to work in my spreadsheet. I'm now wondering if I
can add something in here to enter the words "No Policy" if one of the rows
does not exist under a given customer's data.
If possible, would that go in the VBS code or the formula?

note: See original post at bottom for explanation of what I'm doing.

Thanks.

___________________________


try this function. but it depend on that ur custumernames are in column A
and the cell just below is empty, then a cell with #
just like it seems to be in ur example
otherwise the function have to be modifyed a bit.

put in a regular module then use like this:
=Vlokup("Cust. #1",Sheet1!A1:A100,1,2) - return 2005 (column B)
=Vlokup("Cust. #1",Sheet1!A1:A100,3,2) - return 2003 (column B)
=Vlokup("Cust. #1",Sheet1!A1:A100,0,2) - return 1999 (0=first year)
=Vlokup("Cust. #2",Sheet1!A1:A100,5,4) - return 15 (column D)

Function Vlokup(Custumer As String, MyRange As Range, YearNumber, Col)
Dim Mysheet
Dim c As Range, Last
Set Mysheet = MyRange.Parent
Set c = MyRange
Application.Volatile
If YearNumber < 0 Then
Vlokup = Mysheet.Cells(c.Find(Custumer, LookIn:=xlValues).Row +
YearNumber + 2, Col)
End If
If YearNumber = 0 Then
Last = c.Find(Custumer, LookIn:=xlValues).Offset(2, 0).End(xlDown).Row
Vlokup = Mysheet.Cells(Last, Col)
End If
End Function

______________________

Hi,

I'm building a sheet that pulls data from another worksheet based on a
customer number, so when I enter a customer number into cell it will pull
specific information. The part I'm stuck on is this....There are varying
numbers of rows below each customers' data depending on the number of years
they have been a customer....one row per year, starting with the current
year. I want to pull data for the pervious year, three years ago, five
years ago and the first year they were a customer. The data looks like
this:

"Cust. #1" "Cust. Name"

# Year Premium Losses Claims.....etc
1 2005 1000 50 1
2 2004 1500 10 2
3 2003 1500 0 0
4 2002 1500 15 1
5 2001 1500 15 1
6 2000 1500 10 1
7 1999 1500 0 0

"Cust. #2" "Cust. Name"

# Year Premium Losses Claims.....etc
1 2005 500 50 1
2 2004 500 10 2
3 2003 500 0 0
4 2002 500 15 1

The column with the # and numbers is actually part of the data, not the
Excel row number. So when I enter a customer number to look up, I need it
to look at only the data for that customer and pull rows 1, 3, 5 and the
last row, whatever it might be.

Is this possible, or am I dreaming?? I hope that makes sense.
Thanks,
Dan


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
Need Help Editing this Function... Dan B Excel Worksheet Functions 0 September 28th 06 12:44 AM
Min Max Editing bkj8890 Excel Worksheet Functions 1 March 27th 06 08:52 PM
text editing function help JenBasch Excel Worksheet Functions 3 September 19th 05 07:41 PM
Manually editing Sort function in VBA havocdragon Excel Programming 1 August 25th 04 01:03 PM
Editing a Row stck2mlon[_29_] Excel Programming 1 June 11th 04 02:55 PM


All times are GMT +1. The time now is 02:12 AM.

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"