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 values into cells from VBA

Status
Not open for further replies.

billheath

Technical User
Mar 17, 2000
299
US
I am not used to running VBA in excel. I wrote a function which passes 2 arguments to the function. I need to insert the calculated value back into a particular cell. I thought I could write a statement:

Range("C4") = N

When the program reaches that step it leaves the function routine with no message and returns to the work sheet. Nothing is in cell "C4".

What am I doing wrong? I looked at an earlier script that I wrote in an ancient version and that statement worked.
Thanks, Bill
 
It depends. Try either:
Code:
Range("C4").Value = "N"
or
Code:
Dim N As String
N = "Something"
Range("C4").Value = N

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Thi,

"I wrote a function..."

What function, cuz your example is not at all what usually occurs in a function.
 
This will not work if your function is in worksheet (UDF). Function can change worksheet only if called from vba (also for chain calls).

combo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top