ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   assign variable to a range (https://www.excelbanter.com/excel-programming/435315-assign-variable-range.html)

Alberto Ast[_2_]

assign variable to a range
 
I have saved an activecell value to a variable

xlastdev = ActiveCell.Value

Then have saved an activecell adress to anotehr variable

xnextDev = ActiveCell.Address

I want to assign the last value to the next address

Range(xnextDev).Value = xlastdev

But it does not work... it fail at the last command.

Jacob Skaria

assign variable to a range
 
--It does work..Try the below code in Step Into mode (use F8 instead of F5)

--You are writing the stored value to the same cell

xlastdev = ActiveCell.Value
xnextDev = ActiveCell.Address

Range(xnextDev).ClearContents
Msgbox "Cleared"

Range(xnextDev).Value = xlastdev

--If you are looking to write to the next cell try
Range(xnextDev).OffSet(1) = xlastdev


If this post helps click Yes
---------------
Jacob Skaria


"Alberto Ast" wrote:

I have saved an activecell value to a variable

xlastdev = ActiveCell.Value

Then have saved an activecell adress to anotehr variable

xnextDev = ActiveCell.Address

I want to assign the last value to the next address

Range(xnextDev).Value = xlastdev

But it does not work... it fail at the last command.



All times are GMT +1. The time now is 01:53 PM.

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