Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Stanley
 
Posts: n/a
Default VLOOKUP calendar dates

I have a sheet that has 5 columns
(DayName,CalendarDay,Impact,Holiday,Result). The basic idea is that it has
every day in the year listed (and actually goes out to the beginning of
2008). The Impact column is what holds the modifier for dates. If there is a
holiday then we have to add a Plus/Minus modifier in this column which tells
the formula to add or subtract days for cutoffs on delivery or receiving. Now
what I am trying to do (from a module not formula because formulas get to
messy in large spreadsheets) is write a function that does a lookup on this
page and returns the Impact for that day of the year. However, when I run my
code I get NOTHING, ZIP, not even a ZERO back. I put error code in to see if
the code was getting an error and nothing.

Also if anyone has a better example for the data section I am ready to hear
it. At this point I figure to cut the page data down by removing days that
have 0 Impact. I have inherited this spreadsheet and I am trying to update it
to work better. We have several people who use versions of this spreadsheet
and make mistakes on it because they do not understand the formulas, so I am
putting all that I can into modules.

[sample data]
Day Impact Holiday Result

Sat 12/24/05 -1 Christmas Eve 12/23/05
Sun 12/25/05 -2 Christmas Day 12/23/05
Mon 12/26/05 0 12/26/05
Tue 12/27/05 0 12/27/05
Wed 12/28/05 0 12/28/05
Thu 12/29/05 0 12/29/05
Fri 12/30/05 0 12/30/05
Sat 12/31/05 -1 New Years Eve 12/30/05
Sun 01/01/06 -2 New Years Day 12/30/05

[/sample data]

Code:
Function doLookup(data As String)
On Error GoTo ProcessError
If LCase(data) = "omit" Or data = "" Then
doLookup = 0
Exit Function
End If
Dim data1 As Date
data1 = data
Dim myRange As Range
Set myRange = Worksheets("Tables").Range("$B$4:$C$1100")

MsgBox (Application.WorksheetFunction.VLookup(data1, myRange, 2, False))
Exit Function

ProcessError:
MsgBox (Err.Description)
Resume
End Function
  #2   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default VLOOKUP calendar dates

It sounds to me that you are trying to emulate the NETWORKDAYS Analysis
Toolpak function, which calculates days between two dates, and can ignore
holidays.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Stanley" wrote in message
...
I have a sheet that has 5 columns
(DayName,CalendarDay,Impact,Holiday,Result). The basic idea is that it has
every day in the year listed (and actually goes out to the beginning of
2008). The Impact column is what holds the modifier for dates. If there is

a
holiday then we have to add a Plus/Minus modifier in this column which

tells
the formula to add or subtract days for cutoffs on delivery or receiving.

Now
what I am trying to do (from a module not formula because formulas get to
messy in large spreadsheets) is write a function that does a lookup on

this
page and returns the Impact for that day of the year. However, when I run

my
code I get NOTHING, ZIP, not even a ZERO back. I put error code in to see

if
the code was getting an error and nothing.

Also if anyone has a better example for the data section I am ready to

hear
it. At this point I figure to cut the page data down by removing days that
have 0 Impact. I have inherited this spreadsheet and I am trying to update

it
to work better. We have several people who use versions of this

spreadsheet
and make mistakes on it because they do not understand the formulas, so I

am
putting all that I can into modules.

[sample data]
Day Impact Holiday Result

Sat 12/24/05 -1 Christmas Eve 12/23/05
Sun 12/25/05 -2 Christmas Day 12/23/05
Mon 12/26/05 0 12/26/05
Tue 12/27/05 0 12/27/05
Wed 12/28/05 0 12/28/05
Thu 12/29/05 0 12/29/05
Fri 12/30/05 0 12/30/05
Sat 12/31/05 -1 New Years Eve 12/30/05
Sun 01/01/06 -2 New Years Day 12/30/05

[/sample data]

Code:
 Function doLookup(data As String)
 On Error GoTo ProcessError
     If LCase(data) = "omit" Or data = "" Then
         doLookup = 0
         Exit Function
     End If
     Dim data1 As Date
     data1 = data
     Dim myRange As Range
     Set myRange = Worksheets("Tables").Range("$B$4:$C$1100")

     MsgBox (Application.WorksheetFunction.VLookup(data1, myRange, 2,
Code:
False))
     Exit Function

 ProcessError:
     MsgBox (Err.Description)
     Resume
 End Function
 



  #3   Report Post  
Posted to microsoft.public.excel.misc
Stanley
 
Posts: n/a
Default VLOOKUP calendar dates

Actually no that does not help at all. If the day that a item is shipped out
falls on a holiday I need to calculate weather to set the cutoff earlier than
that day or in the event that an item in scheduled to be received on a
weekend and the monday is a holiday then I need to advance the pickup date
beyond the holiday or weekend. The weekend part is not a problem it is the
lookup of the holidays.

"Bob Phillips" wrote:

It sounds to me that you are trying to emulate the NETWORKDAYS Analysis
Toolpak function, which calculates days between two dates, and can ignore
holidays.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Stanley" wrote in message
...
I have a sheet that has 5 columns
(DayName,CalendarDay,Impact,Holiday,Result). The basic idea is that it has
every day in the year listed (and actually goes out to the beginning of
2008). The Impact column is what holds the modifier for dates. If there is

a
holiday then we have to add a Plus/Minus modifier in this column which

tells
the formula to add or subtract days for cutoffs on delivery or receiving.

Now
what I am trying to do (from a module not formula because formulas get to
messy in large spreadsheets) is write a function that does a lookup on

this
page and returns the Impact for that day of the year. However, when I run

my
code I get NOTHING, ZIP, not even a ZERO back. I put error code in to see

if
the code was getting an error and nothing.

Also if anyone has a better example for the data section I am ready to

hear
it. At this point I figure to cut the page data down by removing days that
have 0 Impact. I have inherited this spreadsheet and I am trying to update

it
to work better. We have several people who use versions of this

spreadsheet
and make mistakes on it because they do not understand the formulas, so I

am
putting all that I can into modules.

[sample data]
Day Impact Holiday Result

Sat 12/24/05 -1 Christmas Eve 12/23/05
Sun 12/25/05 -2 Christmas Day 12/23/05
Mon 12/26/05 0 12/26/05
Tue 12/27/05 0 12/27/05
Wed 12/28/05 0 12/28/05
Thu 12/29/05 0 12/29/05
Fri 12/30/05 0 12/30/05
Sat 12/31/05 -1 New Years Eve 12/30/05
Sun 01/01/06 -2 New Years Day 12/30/05

[/sample data]

Code:
  Function doLookup(data As String)
  On Error GoTo ProcessError
      If LCase(data) = "omit" Or data = "" Then
          doLookup = 0
          Exit Function
      End If
      Dim data1 As Date
      data1 = data
      Dim myRange As Range
      Set myRange = Worksheets("Tables").Range("$B$4:$C$1100")
 
      MsgBox (Application.WorksheetFunction.VLookup(data1, myRange, 2,
Code:
 False))
      Exit Function
 
  ProcessError:
      MsgBox (Err.Description)
      Resume
  End Function
  




  #4   Report Post  
Posted to microsoft.public.excel.misc
Niek Otten
 
Posts: n/a
Default VLOOKUP calendar dates

This one does it:

Function doLookup(data)
On Error GoTo ProcessError
If LCase(data) = "omit" Or data = "" Then
doLookup = 0
Exit Function
End If
Dim data1 As Double
data1 = data
Dim myRange As Range
Set myRange = Range("$B$4:$C$1100")

MsgBox (Application.VLookup(data1, myRange, 2, False))
Exit Function

ProcessError:
MsgBox (Err.Description)
Resume
End Function

But there are still problems with your error routine, which is in an
infinite loop

--
Kind regards,

Niek Otten


"Stanley" wrote in message
...
I have a sheet that has 5 columns
(DayName,CalendarDay,Impact,Holiday,Result). The basic idea is that it has
every day in the year listed (and actually goes out to the beginning of
2008). The Impact column is what holds the modifier for dates. If there is
a
holiday then we have to add a Plus/Minus modifier in this column which
tells
the formula to add or subtract days for cutoffs on delivery or receiving.
Now
what I am trying to do (from a module not formula because formulas get to
messy in large spreadsheets) is write a function that does a lookup on
this
page and returns the Impact for that day of the year. However, when I run
my
code I get NOTHING, ZIP, not even a ZERO back. I put error code in to see
if
the code was getting an error and nothing.

Also if anyone has a better example for the data section I am ready to
hear
it. At this point I figure to cut the page data down by removing days that
have 0 Impact. I have inherited this spreadsheet and I am trying to update
it
to work better. We have several people who use versions of this
spreadsheet
and make mistakes on it because they do not understand the formulas, so I
am
putting all that I can into modules.

[sample data]
Day Impact Holiday Result

Sat 12/24/05 -1 Christmas Eve 12/23/05
Sun 12/25/05 -2 Christmas Day 12/23/05
Mon 12/26/05 0 12/26/05
Tue 12/27/05 0 12/27/05
Wed 12/28/05 0 12/28/05
Thu 12/29/05 0 12/29/05
Fri 12/30/05 0 12/30/05
Sat 12/31/05 -1 New Years Eve 12/30/05
Sun 01/01/06 -2 New Years Day 12/30/05

[/sample data]

Code:
 Function doLookup(data As String)
 On Error GoTo ProcessError
    If LCase(data) = "omit" Or data = "" Then
        doLookup = 0
        Exit Function
    End If
    Dim data1 As Date
    data1 = data
    Dim myRange As Range
    Set myRange = Worksheets("Tables").Range("$B$4:$C$1100")

    MsgBox (Application.WorksheetFunction.VLookup(data1, myRange, 2,
 False))
    Exit Function

 ProcessError:
    MsgBox (Err.Description)
    Resume
 End Function



  #5   Report Post  
Posted to microsoft.public.excel.misc
Stanley
 
Posts: n/a
Default VLOOKUP calendar dates

Thanks that helped.

"Niek Otten" wrote:

This one does it:

Function doLookup(data)
On Error GoTo ProcessError
If LCase(data) = "omit" Or data = "" Then
doLookup = 0
Exit Function
End If
Dim data1 As Double
data1 = data
Dim myRange As Range
Set myRange = Range("$B$4:$C$1100")

MsgBox (Application.VLookup(data1, myRange, 2, False))
Exit Function

ProcessError:
MsgBox (Err.Description)
Resume
End Function

But there are still problems with your error routine, which is in an
infinite loop

--
Kind regards,

Niek Otten


"Stanley" wrote in message
...
I have a sheet that has 5 columns
(DayName,CalendarDay,Impact,Holiday,Result). The basic idea is that it has
every day in the year listed (and actually goes out to the beginning of
2008). The Impact column is what holds the modifier for dates. If there is
a
holiday then we have to add a Plus/Minus modifier in this column which
tells
the formula to add or subtract days for cutoffs on delivery or receiving.
Now
what I am trying to do (from a module not formula because formulas get to
messy in large spreadsheets) is write a function that does a lookup on
this
page and returns the Impact for that day of the year. However, when I run
my
code I get NOTHING, ZIP, not even a ZERO back. I put error code in to see
if
the code was getting an error and nothing.

Also if anyone has a better example for the data section I am ready to
hear
it. At this point I figure to cut the page data down by removing days that
have 0 Impact. I have inherited this spreadsheet and I am trying to update
it
to work better. We have several people who use versions of this
spreadsheet
and make mistakes on it because they do not understand the formulas, so I
am
putting all that I can into modules.

[sample data]
Day Impact Holiday Result

Sat 12/24/05 -1 Christmas Eve 12/23/05
Sun 12/25/05 -2 Christmas Day 12/23/05
Mon 12/26/05 0 12/26/05
Tue 12/27/05 0 12/27/05
Wed 12/28/05 0 12/28/05
Thu 12/29/05 0 12/29/05
Fri 12/30/05 0 12/30/05
Sat 12/31/05 -1 New Years Eve 12/30/05
Sun 01/01/06 -2 New Years Day 12/30/05

[/sample data]

Code:
  Function doLookup(data As String)
  On Error GoTo ProcessError
     If LCase(data) = "omit" Or data = "" Then
         doLookup = 0
         Exit Function
     End If
     Dim data1 As Date
     data1 = data
     Dim myRange As Range
     Set myRange = Worksheets("Tables").Range("$B$4:$C$1100")
 
     MsgBox (Application.WorksheetFunction.VLookup(data1, myRange, 2,
  False))
     Exit Function
 
  ProcessError:
     MsgBox (Err.Description)
     Resume
  End Function
 






  #6   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default VLOOKUP calendar dates

So how about putting the holidays in a list, say M1:M20, and use Conditional
Formatting on the pickup date (say cell D2)with a formula of

=ISNUMBER(MATCH(D2,$M$1:$M$20,0))

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Stanley" wrote in message
...
Actually no that does not help at all. If the day that a item is shipped

out
falls on a holiday I need to calculate weather to set the cutoff earlier

than
that day or in the event that an item in scheduled to be received on a
weekend and the monday is a holiday then I need to advance the pickup date
beyond the holiday or weekend. The weekend part is not a problem it is the
lookup of the holidays.

"Bob Phillips" wrote:

It sounds to me that you are trying to emulate the NETWORKDAYS Analysis
Toolpak function, which calculates days between two dates, and can

ignore
holidays.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Stanley" wrote in message
...
I have a sheet that has 5 columns
(DayName,CalendarDay,Impact,Holiday,Result). The basic idea is that it

has
every day in the year listed (and actually goes out to the beginning

of
2008). The Impact column is what holds the modifier for dates. If

there is
a
holiday then we have to add a Plus/Minus modifier in this column which

tells
the formula to add or subtract days for cutoffs on delivery or

receiving.
Now
what I am trying to do (from a module not formula because formulas get

to
messy in large spreadsheets) is write a function that does a lookup on

this
page and returns the Impact for that day of the year. However, when I

run
my
code I get NOTHING, ZIP, not even a ZERO back. I put error code in to

see
if
the code was getting an error and nothing.

Also if anyone has a better example for the data section I am ready to

hear
it. At this point I figure to cut the page data down by removing days

that
have 0 Impact. I have inherited this spreadsheet and I am trying to

update
it
to work better. We have several people who use versions of this

spreadsheet
and make mistakes on it because they do not understand the formulas,

so I
am
putting all that I can into modules.

[sample data]
Day Impact Holiday Result

Sat 12/24/05 -1 Christmas Eve 12/23/05
Sun 12/25/05 -2 Christmas Day 12/23/05
Mon 12/26/05 0 12/26/05
Tue 12/27/05 0 12/27/05
Wed 12/28/05 0 12/28/05
Thu 12/29/05 0 12/29/05
Fri 12/30/05 0 12/30/05
Sat 12/31/05 -1 New Years Eve 12/30/05
Sun 01/01/06 -2 New Years Day 12/30/05

[/sample data]

Code:
   Function doLookup(data As String)
   On Error GoTo ProcessError
       If LCase(data) = "omit" Or data = "" Then
           doLookup = 0
           Exit Function
       End If
       Dim data1 As Date
       data1 = data
       Dim myRange As Range
       Set myRange = Worksheets("Tables").Range("$B$4:$C$1100")
  
       MsgBox (Application.WorksheetFunction.VLookup(data1, myRange, 2,
Code:
  False))
       Exit Function
  
   ProcessError:
       MsgBox (Err.Description)
       Resume
   End Function
   






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
How do I create a schedule from a list of dates ? Gavin Morris Charts and Charting in Excel 2 October 28th 10 04:08 PM
Calendar - vlookup based on dates Scott Excel Worksheet Functions 10 February 12th 09 11:22 AM
Can you export dates in Excel to a calendar? lexi95 Excel Discussion (Misc queries) 1 November 22nd 05 10:10 PM
looking for a calendar template that I can import multiple dates bkrizman Excel Discussion (Misc queries) 0 June 1st 05 11:16 PM
Ploting dates against a calendar and not as a simple events Barb Reinhardt Charts and Charting in Excel 2 January 22nd 05 02:41 AM


All times are GMT +1. The time now is 09: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"