Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 136
Default How to Insert Variables into Formula's

I have the Following Code. I understand it is not optimized, the
question is how do i place the captured tab name in the formula. what
I am trying is not working.

Public Sub Tester001()

Dim strClickedSht As String
Dim TabName As String

Sheets("Unit 2 Week 2 Test Standards An").Select
strClickedSht = ActiveSheet.Name
TabName = strClickedSht
MsgBox TabName 'for testing
Sheets("Standard Analysis").Select
Range("A6").Select
ActiveCell.FormulaR1C1 = "=('TabName'!R[2]C)"
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 587
Default How to Insert Variables into Formula's

hi Ardy,

ActiveCell.FormulaR1C1 = "=('" & TabName & "'!R[2]C)"

or

ActiveCell.Formula = "=('" & TabName & "'!A8)"


--
isabelle



Le 2011-12-12 17:22, Ardy a écrit :
I have the Following Code. I understand it is not optimized, the
question is how do i place the captured tab name in the formula. what
I am trying is not working.

Public Sub Tester001()

Dim strClickedSht As String
Dim TabName As String

Sheets("Unit 2 Week 2 Test Standards An").Select
strClickedSht = ActiveSheet.Name
TabName = strClickedSht
MsgBox TabName 'for testing
Sheets("Standard Analysis").Select
Range("A6").Select
ActiveCell.FormulaR1C1 = "=('TabName'!R[2]C)"
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 136
Default How to Insert Variables into Formula's

Thank You.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default How to Insert Variables into Formula's

?Optimized...

Public Sub Tester001()
Const TabName As String = "Unit 2 Week 2 Test Standards An"
Sheets("Standard Analysis").Range("A6").FormulaR1C1 = _
"=('" & TabName & "'!R[2]C)"
End Sub

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default How to Insert Variables into Formula's

...or this one-liner:

Public Sub Tester001()
Sheets("Standard Analysis").Range("A6").FormulaR1C1 = _
"=('Unit 2 Week 2 Test Standards An'!R[2]C)"
End Sub

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


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
formula's time conversion[_2_] Excel Discussion (Misc queries) 3 February 7th 09 10:35 PM
Storing variables in a macro and using those variables to performcalculations. [email protected] Excel Programming 3 December 10th 07 04:13 PM
can excel automatically collect variables to redue a formula's si. JeffV Excel Discussion (Misc queries) 1 July 6th 07 10:42 PM
Insert dummy variables Chris_t_2k5[_2_] Excel Programming 2 February 26th 06 01:27 PM
Need Help w/Formula's sunrosejenn Excel Worksheet Functions 5 October 24th 05 07:33 PM


All times are GMT +1. The time now is 04:34 PM.

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"