Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Changing Cells, How to

How do I change a cell value from my VM Macro?

I think this should do it
CELLS(4,4) = "NEW VALUE"
but it doesn't seem to.

I've also tried
ACTIVECELL.CELLS(4,4) = "NEW VALUE"

What am I missing? I'm sure it's obvious, but I can't figure it out.

Thanks,
Mac


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Changing Cells, How to

Cells(4,4) = "New Value"
will work, unless you have some form of protection on.

It would be more precise to use

Cells(4,4).Value = "New Value"
or
Cells(4,4).Text = "New Value"

Activecell.cells(4,4) = "New Value"
should also work placing the value into the cell offset 4 rows and 4 columns
from the activecell

Cheers
Nigel



"Mac Lingo" wrote in message
ink.net...
How do I change a cell value from my VM Macro?

I think this should do it
CELLS(4,4) = "NEW VALUE"
but it doesn't seem to.

I've also tried
ACTIVECELL.CELLS(4,4) = "NEW VALUE"

What am I missing? I'm sure it's obvious, but I can't figure it out.

Thanks,
Mac




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Changing Cells, How to

IS your target worksheet active? Try being explicit, that is

Worksheets("Sheet1").Cells(4,4).Value = "NEW VALUE"

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Mac Lingo" wrote in message
ink.net...
How do I change a cell value from my VM Macro?

I think this should do it
CELLS(4,4) = "NEW VALUE"
but it doesn't seem to.

I've also tried
ACTIVECELL.CELLS(4,4) = "NEW VALUE"

What am I missing? I'm sure it's obvious, but I can't figure it out.

Thanks,
Mac




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Changing Cells, How to

Bob,
This is the line of code that does the write
Worksheets("Sheet3").Cells(4, 4).Value = "String"

When I execute this line, the values in the "Quick Watch" area goes "out of
context".
This code is called from the ActiveWorkSheet and I need to update another
cell on the same line.
I have figured out how to get the line number, but still can't do the write.

Thanks again for your help.

Capt Mac
Ocean Rider (Pacific right now, but am looking forward to the British Isles
one of these days)


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Changing Cells, How to

Not sure on this one. Is the sheet or the cell protected?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Mac Lingo" wrote in message
nk.net...
Bob,
This is the line of code that does the write
Worksheets("Sheet3").Cells(4, 4).Value = "String"

When I execute this line, the values in the "Quick Watch" area goes "out

of
context".
This code is called from the ActiveWorkSheet and I need to update another
cell on the same line.
I have figured out how to get the line number, but still can't do the

write.

Thanks again for your help.

Capt Mac
Ocean Rider (Pacific right now, but am looking forward to the British

Isles
one of these days)






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Changing Cells, How to

Bob,
I don't know how to protect anything; haven't gotten that far in haveing to
VB Program.

SO I think the answer to that is NO, but how would I know.

Also, I got a Bad Address bounce back on your email address. Any idea why.
Maybe our Patriot Act won't let emails out of the US any more.

Capt Mac

"Bob Phillips" wrote in message
...
Not sure on this one. Is the sheet or the cell protected?



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Changing Cells, How to - You can't change the enviornment from a Function call.

Missing Information from the Problem - The VB Macro is a FUNCTION being
called from the spreadsheet.

The Solution: - A Rule: You CAN'T change the enviornment a Function is being
called from. I suppose this is because it too easily can end up in an
infinite loop, but for whatever reason EXCEL won't allow it.

Answer: You have to write a SUBROUTINE instead.


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Changing Cells, How to - You can't change the enviornment from a Function call.

Marc,

Not correct. Try this

Function ChangeIt(rng As Range, val)
rng.Value = val
End Function

and in the worksheet, use

=ChangeIt(D4,"NEW VALUE")

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Mac Lingo" wrote in message
ink.net...
Missing Information from the Problem - The VB Macro is a FUNCTION being
called from the spreadsheet.

The Solution: - A Rule: You CAN'T change the enviornment a Function is

being
called from. I suppose this is because it too easily can end up in an
infinite loop, but for whatever reason EXCEL won't allow it.

Answer: You have to write a SUBROUTINE instead.




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Enter not changing cells Eric Excel Discussion (Misc queries) 1 February 9th 09 07:10 AM
Adjustable Cells (Changing Cells) Limit - Solver Marcio Excel Discussion (Misc queries) 0 April 7th 08 04:41 PM
how do you name the changing cells in a scenario? Natalie M Excel Discussion (Misc queries) 1 August 14th 06 02:21 PM
changing all cells jeremy via OfficeKB.com New Users to Excel 3 June 6th 05 07:40 PM
changing cells from function Alex Colomb Excel Programming 4 April 20th 04 05:47 AM


All times are GMT +1. The time now is 10:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"