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: 3
Default Help on combining declared variable and cell formula

Am new in macro. i encountered runtime error trying to develop a sub to do
same work as SUBTOTAL. I had problems on the line the line that has a
combination of declared variable and cell formula: ActiveCell.FormulaR1C1 =
"=RC[-1]+ TOT" Below is the full code.


Dim z As Long
Dim TOT As Double
z = 3
Range("C2").FormulaR1C1 = "=RC[-1]"
TOT = Range("C2").Value

Do While Range("A" & z) < ""

If Range("A" & z).Value = Range("A" & z - 1).Value Then

'Range("C" & z - 1).FormulaR1C1 = "=RC[-1]+R[-1]C"

Range("C" & z).Select
ActiveCell.FormulaR1C1 = "=RC[-1]+ TOT"

TOT = "=RC[-1]" + TOT
Range("C" & z - 1).FormulaR1C1 = 0

Else
Range("A" & z).Select
ActiveCell.FormulaR1C1 = 0

End If
z = z + 1
Loop
 
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
Reference a variable declared in VBA James Excel Worksheet Functions 3 September 12th 08 10:31 PM
Combining formula and cell reference Drew Excel Worksheet Functions 3 May 17th 06 10:52 AM
Help on combining declared variable and cell formula sylink Excel Programming 1 August 12th 05 07:58 PM
need some help combining a variable Gary Keramidas[_2_] Excel Programming 7 July 5th 05 02:51 PM
Combining variable names Bernie Gaile Excel Programming 2 December 28th 03 09:24 PM


All times are GMT +1. The time now is 12:27 AM.

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"