Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default Change cell reference type

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Change cell reference type

KeyCell = ActiveCell.Address(0,0)

--
---
HTH

Bob

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



"Ladymuck" wrote in message
...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 272
Default Change cell reference type

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default Change cell reference type

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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Change cell reference type

Why are you using activecell to begin with? Wouldn't an absolute address be
better here?


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default Change cell reference type

Thanks for your suggestions, they work brilliantly.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Shortcut to change change cell reference to Absolute reference? richk Excel Worksheet Functions 12 December 5th 09 12:24 AM
change the reference type of multiple formulas Derfel Excel Discussion (Misc queries) 1 March 19th 08 05:05 PM
change the reference type of multiple formulas Derfel Excel Discussion (Misc queries) 0 March 19th 08 04:32 PM
change change cell reference to Absolute reference art Excel Discussion (Misc queries) 5 March 13th 08 02:41 AM
How do I locate a highlighted cell as a cross hair type reference Mike Setting up and Configuration of Excel 2 October 6th 05 04:41 AM


All times are GMT +1. The time now is 09:27 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"