ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel and VBA how to call a procedure from an excel "cell" (https://www.excelbanter.com/excel-programming/339280-excel-vba-how-call-procedure-excel-cell.html)

DMB

Excel and VBA how to call a procedure from an excel "cell"
 
Is there a way to call a procedure that I have already written in vba from a
cell. For instance, can I put something like the following into a cell

Call CopyFunctionToAdjacentCell()


This is the VBA Code that I am using right now. It works great. If I could
only cut and paste it into the cell I would be set.
Cells(4 + StartRow, 4) = "'" & Cells(4 + StartRow, 2).Formula

Is thee a way to accomplish the same thing within Excel?
=A1.Formula ???

Problem is that I always get the result on the equation.


DMB

Excel and VBA how to call a procedure from an excel "cell"
 

I also need to perform other worksheet maintence from with in Excel. Such
as, Changing all the headers for all the worksheets within the current
workbook of which there are 5.

Is there a way to perform these kind of things or is this a useless quest. I
am trying to make an application that the company owner will be able to
understand. He will never understand the VBA stuff. He doesn't even
understand most of the excel stuff. He needs to be able to work on these
functions later or the whole project will be scrap.

When I leave I don't want to go back. And I hope that he is still happy and
up and runnng.

Gary''s Student

Excel and VBA how to call a procedure from an excel "cell"
 
You can do it if your VBA code is a function. If you can somehow enclose
your code in a UDF, then the UDF can be used in the woorkshhet.


See my posting earlier today w.r.t. Using VBA Functions in a worksheet.
--
Gary''s Student


"DMB" wrote:

Is there a way to call a procedure that I have already written in vba from a
cell. For instance, can I put something like the following into a cell

Call CopyFunctionToAdjacentCell()


This is the VBA Code that I am using right now. It works great. If I could
only cut and paste it into the cell I would be set.
Cells(4 + StartRow, 4) = "'" & Cells(4 + StartRow, 2).Formula

Is thee a way to accomplish the same thing within Excel?
=A1.Formula ???

Problem is that I always get the result on the equation.


DMB

Excel and VBA how to call a procedure from an excel "cell"
 
Hey thanks for the information. But! I can find the insert function dialog
box but I can't find out how to insert and write functions Am I supposed to
do that in the VBA environment?

Thanks, You must have a million questions to answer!



"Gary''s Student" wrote:

You can do it if your VBA code is a function. If you can somehow enclose
your code in a UDF, then the UDF can be used in the woorkshhet.


See my posting earlier today w.r.t. Using VBA Functions in a worksheet.
--
Gary''s Student


"DMB" wrote:

Is there a way to call a procedure that I have already written in vba from a
cell. For instance, can I put something like the following into a cell

Call CopyFunctionToAdjacentCell()


This is the VBA Code that I am using right now. It works great. If I could
only cut and paste it into the cell I would be set.
Cells(4 + StartRow, 4) = "'" & Cells(4 + StartRow, 2).Formula

Is thee a way to accomplish the same thing within Excel?
=A1.Formula ???

Problem is that I always get the result on the equation.



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

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