PC Review


Reply
Thread Tools Rate Thread

assign variable to a range

 
 
Alberto Ast
Guest
Posts: n/a
 
      23rd Oct 2009
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.
 
Reply With Quote
 
 
 
 
Jacob Skaria
Guest
Posts: n/a
 
      23rd Oct 2009
--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.

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Assign range to variable for sort Michael Conroy Microsoft Excel Programming 2 11th Nov 2009 06:48 AM
Assign copied range to a variable johnmasvou Microsoft Excel Programming 3 20th Mar 2009 10:44 AM
VBA Excel how to assign name in variable range Mouimet Microsoft Excel Programming 4 14th Nov 2008 05:56 PM
range variable won't assign (chartobject.topleftcell property) Matthew Dodds Microsoft Excel Programming 2 16th Nov 2005 02:25 PM
How to assign a variable in a range select Paul Microsoft Excel Programming 5 3rd Jun 2005 11:50 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:56 PM.