Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

R1C1 with Variables

Status
Not open for further replies.

kaplin

Programmer
Mar 14, 2003
11
CA
When I do this:

'text = "=subtotal(9," & Chr(64 + col) & "2:" & Chr(64 + col) & lastrow & ")"

where col and lastrow are integers, I get an error because it inserts single parenthesis into the formala in the cell.

Ex: =subtotal(9,'A20':'B60')

Any idea how I get rid of the parenthesis - am I concatinating wrong?
 
I can't tell what you are realy trying to do, but this may point you in the right direction:
Code:
Sub test()
  col = 2
  lastrow = 40
  Cells(1, 1).Formula = "=subtotal(9," & Chr(64 + col) & "2:" & Chr(64 + col) & lastrow & ")"
End Sub
 
Thanks! I didn't realize there was a difference between Formula and FormulaR1C1. Changing it did the trick though..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top