ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Transporting Variable from macro to spreadsheet (https://www.excelbanter.com/excel-programming/384200-transporting-variable-macro-spreadsheet.html)

Ken Newman

Transporting Variable from macro to spreadsheet
 
I have calculated a variable 'n' in a macro and want to put it into a
spreadsheet.
The expression ActiveCell.Formula = "= Max(R3Cn:R3C256)" doesn't work,
although substituting a number for n does work
Any solutions would be appreciated
--
Ken

Chip Pearson

Transporting Variable from macro to spreadsheet
 
Ken,

Try something like
ActiveCell.Formula = "= Max(R3C" & N & ":R3C256)"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)

"Ken Newman" wrote in message
...
I have calculated a variable 'n' in a macro and want to put it into a
spreadsheet.
The expression ActiveCell.Formula = "= Max(R3Cn:R3C256)" doesn't work,
although substituting a number for n does work
Any solutions would be appreciated
--
Ken




Dave Peterson

Transporting Variable from macro to spreadsheet
 
Although Chip's line of code may work, I bet he meant:

ActiveCell.FormulaR1C1 = "= Max(R3C" & N & ":R3C256)"


Chip Pearson wrote:

Ken,

Try something like
ActiveCell.Formula = "= Max(R3C" & N & ":R3C256)"

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)

"Ken Newman" wrote in message
...
I have calculated a variable 'n' in a macro and want to put it into a
spreadsheet.
The expression ActiveCell.Formula = "= Max(R3Cn:R3C256)" doesn't work,
although substituting a number for n does work
Any solutions would be appreciated
--
Ken


--

Dave Peterson


All times are GMT +1. The time now is 11:40 AM.

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