• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Populate 1 cell

Hello! I am drawing a complete blank while writing a simple macro. I need to populate a single cell with a text (without actually writing subroutines - just in Excel). For instance, I need to display "sample text" in A1. How do I do it?


Thanks!
 
Good evening phillygirl777


If it is a simple macro as you say then why not use the macro recorder, when you are done open up the macro and read the code then you can use/tidy/expand as you see fit
 
Thanks, this is exactly what I did, but nothing showed up in A1 when I ran the macro. Do I have to activate any add-ins? Thanks again!
 
You shouldn't have to. activate any macros. "something" should have happened. Note that the code I used above didn't reference a specific worksheet or workbook, so it would/should have just modifed A1 of the currently active worksheet, unless this code was in a Sheet module rather than a regular module. In Sheet module, undefined objects are refered to the owner sheet by default, rather than the active sheet.


If there more to the code that we should be aware of? Does A1 have any special formatting? (white text, Conditional formatting, etc)
 
Is there anything else going on in the macro that's affecting things? Another test would be to just run this short script

[pre]
Code:
Sub Test()
Range("A1") = "sample text"
End Sub
[/pre]
If it doesn't work, then we know something is going on with the XL sheet. If it does, there's something going on with your code.
 
Back
Top