ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Placing a Variable Properly (https://www.excelbanter.com/excel-worksheet-functions/98337-placing-variable-properly.html)

Dennis

Placing a Variable Properly
 
Hi, I'm trying to get the rr variable syntax to work. I tried putting it in ()
and preceding it by & and $ and I cant get it to work. Any hep would be
appreciated.

Tia, Dennis


Sub Countif()
Dim r As String
Dim rr As Variant
Range("L1").Select
rr = Application.InputBox("Enter where to count, 11 = A, 10 = B.....")
ActiveCell.FormulaR1C1 = "=COUNTIF(C[-rr)],RC[-rr])"
r = Application.InputBox("Enter a Range L1 Thru ?", "L1:")
Selection.AutoFill Destination:=Range(r), Type:=xlFillDefault
Range("A1").Select
End Sub

Ardus Petus

Placing a Variable Properly
 
ActiveCell.FormulaR1C1 = "=COUNTIF(C[-" & rr &"],RC[-" & rr& "])"

HTH
--
AP

"Dennis" a écrit dans le message de news:
...
Hi, I'm trying to get the rr variable syntax to work. I tried putting it
in ()
and preceding it by & and $ and I cant get it to work. Any hep would be
appreciated.

Tia, Dennis


Sub Countif()
Dim r As String
Dim rr As Variant
Range("L1").Select
rr = Application.InputBox("Enter where to count, 11 = A, 10 = B.....")
ActiveCell.FormulaR1C1 = "=COUNTIF(C[-rr)],RC[-rr])"
r = Application.InputBox("Enter a Range L1 Thru ?", "L1:")
Selection.AutoFill Destination:=Range(r), Type:=xlFillDefault
Range("A1").Select
End Sub




Dennis

Placing a Variable Properly
 
In article , "Ardus Petus" wrote:
ActiveCell.FormulaR1C1 = "=COUNTIF(C[-" & rr &"],RC[-" & rr& "])"

HTH


Thanx Ardus, that's one I didn't try :)

Dennis


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com