View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
Duncs Duncs is offline
external usenet poster
 
Posts: 65
Default Using Excel functions within VBA

OK, here's what I want to do.

I want to build up a text string, using dates, and then display it.
Contained within that text string, will be the following information:

<today's date : <number of days since start of year : <number of
work days between today's data and a date in a specific cell

What I'm doing is building up a string, as follows:

strVar = Format(Now(), "Short Date")
strVar = """" & strVar & """" &
Application.International(xlListSeparator)
strTempDate = Format(TempDate, "Short Date")
strTempDate = """" & strTempDate & """"
strVar = strVar & strTempDate
strTempDate = "NETWORKDAYS(" & strVar & ")"
S = S & Format(strTempDate)

My theory is:

strVar is set to today's date = 12/07/2007
strVar then has the appropriate separator appended to it =
"12/07/2007",
strTempDate is formatted as a date = 12/11/2007
strTempDate then has the '"' characters added to it = "12/11/2007"
strVar is then set the two values, combined =
"12/07/2007","12/11/2007"

This is where it falls down. What I want to do, is insert the number
of work days that are between the two values. However, with the code
I have above, all I'm getting is the text
"NETWORKDAYS("12/07/2007","12/11/2007")" added to my string.

Can someone help?

Rgds
Duncs