Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting Text (Sorry for the Newb Question)

Status
Not open for further replies.

cjpicc11

Technical User
Jan 24, 2004
25
US
Hey guys,

Just was wondering how I can insert text into a Cell. I'm trying to insert text into a cell with a date.

Something like this "Text" & Date - 7. Just dont know what the keyword is for inserting the text or how I can start up the code. Any help I would appreciate it.

Thank You,
Chris
 
To be clear, are you wanting to do this in VBA? What does "how I can start up the code" mean exactly? ( start to write code/start code running/formulae codes???? )

Cheers, Glenn.

Did you hear about the literalist show-jumper? He broke his nose jumping against the clock.
 
Yes Its VBA, I thought I posted in a VBA Forum didnt I? I searched the helpfile in Excel and found something like this:
With Worksheets(1).Range("e5").AddComment
.Visible = False
.Text "reviewed on " & Date
End With

This just adds the comment and I was just wondering if there is some type of keyword for entering text into a specific Cell. I also do not want it inserted on that active sheet, I would like it inserted on a template that I am using.

Thanks again for your help.
 
Use Range("e5").Value="reviewed on " & Format(Date,"dd-mmm-yy")



Cheers, Glenn.

Did you hear about the literalist show-jumper? He broke his nose jumping against the clock.
 
I get error: "Sub or function not defined" with Use Highlighted.
 
Glen's suggestion was to use

[COLOR=blue white]Range("e5").Value="reviewed on " & Format(Date,"dd-mmm-yy")[/color]

"Use" should not be part of the code.

[tt]_____
[blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ181-2886 before posting.
 
Hey Guys, Thanks again for your help, I would like to know how I can insert this text on a different workbook and not on the active sheet.
I tried entering this code:
ExcelApp.Workbooks("C:\TPS Template2.xls").Worksheet(1).Range("A3").Value = " Week of " & Date - 7
Selection.Font.Bold = True

but received message saying "Subscript is out of range"
 
Any workbook name in the Workbooks collection would not have C:\ in it.



Cheers, Glenn.

Did you hear about the literalist show-jumper? He broke his nose jumping against the clock.
 
You will need to test whether or not the workbook you are trying to write to is opened and then reference it. Although there is also a way using XLM Macros to write a value to a closed workbook.

Is your workbook open?
Will it always be open?
Will this macro be running only on your computer?
How possible is it that the Workbook path will be changed in the future?

You see . . . You can get this to work easily if you are certain that the workbook will be open whenever you run the procedure, but there are other factors that need to be considered in order to write it correctly.



Peace!! [americanflag] [peace] [americanflag]

Mike

Didn't get the answers that you wanted? Then . . . Click Here
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top