Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bob Bob is offline
external usenet poster
 
Posts: 972
Default Referencing a Cell in Macro

I've got the following macro code and what I would like to do is change the
value of [-17] on a a separate sheet -such as Sheet1. For example, this part
of the code in a monthly total so [-17] refers to Feb-08 and in March I would
need to update the macro with [-16] for Mar-08. I would rather update an
excel sheet with this reference that to have to change the macro directly. Is
this possible?

Sub CopyCell1()
Dim X As Long
Dim Sh As Variant
For Each Sh In Array("M", "P", "T", "A", "Mi", "Sm", "H")
For X = 7 To 500
Worksheets(Sh).Range("V" & X).FormulaR1C1 =
"=((RC[-17]/Sheet1!R20C4)*52)"
Next
Next
End Sub

--
Thanks.
Bob
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Referencing a Cell in Macro

Myoff = -17
Worksheets(Sh).Range("V" & X).FormulaR1C1 = _
"=((RC[" & Myoff & "]/Sheet1!R20C4)*52)"


"Bob" wrote:

I've got the following macro code and what I would like to do is change the
value of [-17] on a a separate sheet -such as Sheet1. For example, this part
of the code in a monthly total so [-17] refers to Feb-08 and in March I would
need to update the macro with [-16] for Mar-08. I would rather update an
excel sheet with this reference that to have to change the macro directly. Is
this possible?

Sub CopyCell1()
Dim X As Long
Dim Sh As Variant
For Each Sh In Array("M", "P", "T", "A", "Mi", "Sm", "H")
For X = 7 To 500
Worksheets(Sh).Range("V" & X).FormulaR1C1 =
"=((RC[-17]/Sheet1!R20C4)*52)"
Next
Next
End Sub

--
Thanks.
Bob

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 186
Default Referencing a Cell in Macro

Hi Bob,

Put -17 in cell A1 on Sheet1.

Worksheets(Sh).Range("V" & X) = "=((RC[" & Sheets(1).Range("A1") &
"]/Sheet1!R20C4)*52)"

Hope this helps.
--
Ken Hudson


"Bob" wrote:

I've got the following macro code and what I would like to do is change the
value of [-17] on a a separate sheet -such as Sheet1. For example, this part
of the code in a monthly total so [-17] refers to Feb-08 and in March I would
need to update the macro with [-16] for Mar-08. I would rather update an
excel sheet with this reference that to have to change the macro directly. Is
this possible?

Sub CopyCell1()
Dim X As Long
Dim Sh As Variant
For Each Sh In Array("M", "P", "T", "A", "Mi", "Sm", "H")
For X = 7 To 500
Worksheets(Sh).Range("V" & X).FormulaR1C1 =
"=((RC[-17]/Sheet1!R20C4)*52)"
Next
Next
End Sub

--
Thanks.
Bob

  #4   Report Post  
Posted to microsoft.public.excel.programming
Bob Bob is offline
external usenet poster
 
Posts: 972
Default Referencing a Cell in Macro

Thanks Ken. That works perfectly. If I wanted to add to columns for example
A1 + A2 would I use your code and simply add an + sign?
--
Bob


"Ken Hudson" wrote:

Hi Bob,

Put -17 in cell A1 on Sheet1.

Worksheets(Sh).Range("V" & X) = "=((RC[" & Sheets(1).Range("A1") &
"]/Sheet1!R20C4)*52)"

Hope this helps.
--
Ken Hudson


"Bob" wrote:

I've got the following macro code and what I would like to do is change the
value of [-17] on a a separate sheet -such as Sheet1. For example, this part
of the code in a monthly total so [-17] refers to Feb-08 and in March I would
need to update the macro with [-16] for Mar-08. I would rather update an
excel sheet with this reference that to have to change the macro directly. Is
this possible?

Sub CopyCell1()
Dim X As Long
Dim Sh As Variant
For Each Sh In Array("M", "P", "T", "A", "Mi", "Sm", "H")
For X = 7 To 500
Worksheets(Sh).Range("V" & X).FormulaR1C1 =
"=((RC[-17]/Sheet1!R20C4)*52)"
Next
Next
End Sub

--
Thanks.
Bob

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
referencing a cell in a macro R Dunn Excel Programming 5 February 3rd 07 11:38 AM
Sheet referencing in a macro Nick Hodge Excel Programming 2 December 19th 06 11:15 PM
Sheet referencing in a macro Craig B Excel Programming 0 December 18th 06 09:43 PM
Indirect Referencing in a Macro Jerry Wayland Excel Programming 7 January 17th 06 07:38 PM
File referencing in macro ewan7279 Excel Programming 0 March 2nd 05 03:01 PM


All times are GMT +1. The time now is 03:16 AM.

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"