LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel VBA-use variable in active cell formula problem

Seems simple enough but I cannot find any help on the matter...

I cannot get the required syntax to allow me to use a variable, "i",
within the formula, "=RC[-1]&""/""&RC[&i]"

Sub Macro1()
Dim i As Integer
i = 2

Range("D2").Select
Do While Not IsEmpty(ActiveCell)
ActiveCell.Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "=RC[-1]&""/""&RC[&i]"
ActiveCell.Offset(0, 1).Select
i = -2 + i
Loop
End Sub

Column headings exist in every other column along row 2. I want the
formula to pick up the heading in C2 every time, add a division sign
and then add the heading from the preceding column.

For example if C2's heading reads "Animal", D2's heading reads "Plant"
and F2's heading reads "Fungi". In this example I want the formula to
print "Animal/Plant" in E2 and "Animal/Fungi" in G2.

Thanks for any help!

Ryan


---
Message posted from http://www.ExcelForum.com/

 
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
how to use the active cell in an Excel formula EPMMGR06 Excel Worksheet Functions 3 May 15th 23 07:45 PM
Set a variable to the active cell Richard Excel Discussion (Misc queries) 1 March 24th 08 05:42 PM
referring to formula in a non active cell from active cell nickname Excel Discussion (Misc queries) 1 June 21st 07 12:11 PM
value of active cell into a variable TusaJii Excel Programming 1 January 24th 04 05:54 PM
Problem with Active Cell Refence patterson_m Excel Programming 1 October 10th 03 06:34 PM


All times are GMT +1. The time now is 11:57 PM.

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

About Us

"It's about Microsoft Excel"