Inputting a concatenated string into a cell

P

Peter Rooney

I want to enter a header into a cell on a worksheet whcih contains text and
the current date. I have written a routine to generate the current date,
whcih works fine.

Sub GenTodaysDate()
Dim TodaysDate As String
TodaysDate = DateSerial(Year(ActiveProject.CurrentDate), _
Month(ActiveProject.CurrentDate), _
Day(ActiveProject.CurrentDate))
MsgBox (TodaysDate)
End Sub

But when I try to use the "TodaysDate" variable as part of entering a label,
all I get is the text part (i.e. Service Management Plan - ", with no date.

SetTaskField Field:="Name", Value:="Service Management Plan - " &
TodaysDate, TaskID:=1, ProjectName:="Proj22"

In Excel, I seem to remember using something like "format(date,"dd/mm/yy")
to achieve what i want - can anybody help?

Cheers

Pete
 
J

JimS

Hi Peter,

I just checked that the format command worked - seems ok to me.
e.g.to add a task to the end of the active project with the task name set to
some text with the date

Sub test()
ActiveProject.Tasks.Add
ActiveProject.Tasks(ActiveProject.Tasks.Count).Name = "The date is " &
Format(ActiveProject.CurrentDate, "DD/MMM/YYYY")
End Sub

Cheers
JimS
 
P

Peter Rooney

Jim,

Yep, you were right - what I had to do was create the concatenated string
then substitute it into the "Set Task Field" command as shown below:

SetTaskField Field:="Name", Value:=DateString, TaskID:=1,
ProjectName:="Proj22"

as against trying to carry out the concatenation actually in the command
itself!

SetTaskField Field:="Name", Value:="Service Management Plan - " &
TodaysDate, TaskID:=1, ProjectName:="Proj22"

Thanks for your advice!

Cheers

Pete
 

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

Top