Windows XP VBA - Find Method :: Please Help!

Status
Not open for further replies.
Joined
Jun 26, 2009
Messages
1
Reaction score
0
Hi There,
I am writing a function for a project budget in excel using VBA .
I have a range of columns, each column represents one week and has a week-ending date in row 3 of each column in the range. (as extra weeks can be added, I have named the column range). each row represents a project resource (person) which could have a period (between date x and date z) where they are charged out to the client a a discounted rate. I am wanting to calculate the amount of days in which the resource has worked within the discount period so that I can accurately calculate the resources cost. to do this, I need to place a function in each row which queries the range of columns to find the discount period start date and hold the col number in a variable and then the same with the end date and then calculate all days that the resource has worked between start and finish dates on their row (same row that the function resides in)

I am having trouble getting this to work, could someone please help.

Sorry if this is a bit confusing.

Function DiscountDays()

Dim curRow, curCol, colDateA, colDateB, discFrom, discTo


curRow = Application.ThisCell.Row
curCol = Application.ThisCell.Column
discFrom = Application.ThisCell.Offset(0, -2).Value
discTo = Application.ThisCell.Offset(0, -1).Value


colDateA = Range("activeDate").Find(What:=discFrom) .Row 'Where activeDate id the named range
colDateB = Range("activeDate").Find(What:=discTo).Row


'sum values of cells on this row between these columns inclusive.


DiscountDays = Sum.curRow.Range(Columns(colDateA), Columns(colDateB)) 'output value

End Function
 
Last edited:
Status
Not open for further replies.

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Windows XP vba code help 10
More VBA Help please 2
calculate total hours based on dates 5
Range passed to a function - trying to just move through the range 4
Help! Please! 7
OFFSET LOOKUP function in VBA? 9
Find all in vba 5
Lookup 3

Back
Top