ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Beginners Question (https://www.excelbanter.com/excel-programming/383364-beginners-question.html)

Kman

Beginners Question
 
Hello all,

I wrote a function that returns the value to the cell in which it is
executed and modifies adjacent cell, but apparently you couldn't do that as
functions aren't allowed to READ or MODIFY contents of other cells?

So I have to write a sub procedure it seems. My question to you is, how
could I execute a sub procedure, and how would I pass arguments to it?

Thanks for you assistance.

Gary''s Student

Beginners Question
 
Once you have entered the macro, running it is as easy as :

1. ALT-F8
2. select the macro
3. touch run

Macros can have arguments, but that's mostly for macros called by other
macros or event macros. Usually macros pickup information from worksheet
cells and user input.

For example, you originally tried a function and wanted a result in a cell
and its adjacent neighbor. In using a sub you could just select that cell in
the worksheet and run the macro.

To put a value in the selected cell:

ActiveCell.Value=whatever

to put a value in the adjacent cell:

ActiveCell.Offset(0,1).Value=whichever


start out by reading:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

or

http://www.lqnet.com/Excel/Excel.asp...FSydFQodi1EBpg
--
Gary's Student
gsnu200706


"kMan" wrote:

Hello all,

I wrote a function that returns the value to the cell in which it is
executed and modifies adjacent cell, but apparently you couldn't do that as
functions aren't allowed to READ or MODIFY contents of other cells?

So I have to write a sub procedure it seems. My question to you is, how
could I execute a sub procedure, and how would I pass arguments to it?

Thanks for you assistance.


Kman

Beginners Question
 
Thanks for replying Gary's Student....

I had trouble with running macros as I had defined them as "Private". Taking
it out allows me to select a macro to run.

I have another question for you. How could I run macros over a range of
cells. You know how you could copy a function in cell and paste it over a
range of cells to repeat function. Is it possible to do something with macros
to achieve similar effect?

"Gary''s Student" wrote:

Once you have entered the macro, running it is as easy as :

1. ALT-F8
2. select the macro
3. touch run

Macros can have arguments, but that's mostly for macros called by other
macros or event macros. Usually macros pickup information from worksheet
cells and user input.

For example, you originally tried a function and wanted a result in a cell
and its adjacent neighbor. In using a sub you could just select that cell in
the worksheet and run the macro.

To put a value in the selected cell:

ActiveCell.Value=whatever

to put a value in the adjacent cell:

ActiveCell.Offset(0,1).Value=whichever


start out by reading:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

or

http://www.lqnet.com/Excel/Excel.asp...FSydFQodi1EBpg
--
Gary's Student
gsnu200706


"kMan" wrote:

Hello all,

I wrote a function that returns the value to the cell in which it is
executed and modifies adjacent cell, but apparently you couldn't do that as
functions aren't allowed to READ or MODIFY contents of other cells?

So I have to write a sub procedure it seems. My question to you is, how
could I execute a sub procedure, and how would I pass arguments to it?

Thanks for you assistance.



All times are GMT +1. The time now is 12:05 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com