PC Review


Reply
Thread Tools Rate Thread

Change cell reference type

 
 
=?Utf-8?B?TGFkeW11Y2s=?=
Guest
Posts: n/a
 
      24th Sep 2007
I have the following line in my macro code:
KeyCell = ActiveCell.Address
This is used in the line:
Range("D2").Formula = "=IF('Original Data'!" & KeyCell &
"<>0,'Original Data'!" & KeyCell & ",TODAY())"

It evaluates fine but, further down in my code, I copy this formula down a
large number of rows. Unfortunately, KeyCell is an absolute cell reference
and I want it to be relative. What do I need to do to change this?

Many thanks for your help

 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      24th Sep 2007
KeyCell = ActiveCell.Address(0,0)

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Ladymuck" <(E-Mail Removed)> wrote in message
news:63F76547-7284-49CE-A1E0-(E-Mail Removed)...
>I have the following line in my macro code:
> KeyCell = ActiveCell.Address
> This is used in the line:
> Range("D2").Formula = "=IF('Original Data'!" & KeyCell &
> "<>0,'Original Data'!" & KeyCell & ",TODAY())"
>
> It evaluates fine but, further down in my code, I copy this formula down a
> large number of rows. Unfortunately, KeyCell is an absolute cell reference
> and I want it to be relative. What do I need to do to change this?
>
> Many thanks for your help
>



 
Reply With Quote
 
=?Utf-8?B?Q2hhcmxlcyBDaGlja2VyaW5n?=
Guest
Posts: n/a
 
      24th Sep 2007
KeyCell = ActiveCell.Address(False, False)
the first optional variable is row absolute the second is column. This makes
both relative
--
Charles Chickering

"A good example is twice the value of good advice."


"Ladymuck" wrote:

> I have the following line in my macro code:
> KeyCell = ActiveCell.Address
> This is used in the line:
> Range("D2").Formula = "=IF('Original Data'!" & KeyCell &
> "<>0,'Original Data'!" & KeyCell & ",TODAY())"
>
> It evaluates fine but, further down in my code, I copy this formula down a
> large number of rows. Unfortunately, KeyCell is an absolute cell reference
> and I want it to be relative. What do I need to do to change this?
>
> Many thanks for your help
>

 
Reply With Quote
 
=?Utf-8?B?S2VpdGhsbw==?=
Guest
Posts: n/a
 
      24th Sep 2007
I think you need to make KeyCell = ActiveCell.Address(RowAbsolute:=False,
ColumnAbsolute:=False)

This way the dollar signs are not returned, and when you go to copy it wil
advance the references.

Hope this helps,

Keith

"Ladymuck" wrote:

> I have the following line in my macro code:
> KeyCell = ActiveCell.Address
> This is used in the line:
> Range("D2").Formula = "=IF('Original Data'!" & KeyCell &
> "<>0,'Original Data'!" & KeyCell & ",TODAY())"
>
> It evaluates fine but, further down in my code, I copy this formula down a
> large number of rows. Unfortunately, KeyCell is an absolute cell reference
> and I want it to be relative. What do I need to do to change this?
>
> Many thanks for your help
>

 
Reply With Quote
 
=?Utf-8?B?UGF0cmlja1M=?=
Guest
Posts: n/a
 
      24th Sep 2007
Why are you using activecell to begin with? Wouldn't an absolute address be
better here?
 
Reply With Quote
 
=?Utf-8?B?TGFkeW11Y2s=?=
Guest
Posts: n/a
 
      24th Sep 2007
Thanks for your suggestions, they work brilliantly.

 
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
Shortcut to change change cell reference to Absolute reference? =?Utf-8?B?cmljaGs=?= Microsoft Excel Worksheet Functions 12 5th Dec 2009 12:24 AM
Change color of characters in a cell based of a cell reference kimbobo Microsoft Excel Discussion 2 22nd Mar 2008 01:57 AM
change the reference type of multiple formulas Derfel Microsoft Excel Misc 1 19th Mar 2008 05:05 PM
change the reference type of multiple formulas Derfel Microsoft Excel Misc 0 19th Mar 2008 04:32 PM
change change cell reference to Absolute reference art Microsoft Excel Misc 5 13th Mar 2008 02:41 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:17 AM.