PC Review


Reply
Thread Tools Rate Thread

Addition string from input box in to a formula (eg;R1C1 Formula)

 
 
=?Utf-8?B?RGV2?=
Guest
Posts: n/a
 
      25th Jan 2007
=>I have a file name in the input box which will be entered by the user.
=>How can we call this variable into a formula.
=>for eg: I want to use the file name into a vlook up formula for getting
some information from a different workbook. However, the formula for Vlookup
is got by using Activecell.formular1c1 which allows us to get the formula by
inputting the whole fomula with in codes. Hence, when I call for the variable
file name in the middle of this formula its not recognising.

Need help at the earliest.

Rgds,

Dev,
 
Reply With Quote
 
 
 
 
Member
Join Date: Apr 2006
Posts: 29
 
      25th Jan 2007
Dev,

I have a similar issue.

I have an integer stored in a variable that I want to insert into a R1C1 formula.

The Compiler for VBA has no problem with this, however, there is an error in run-time, Application or user defined error.

If you hear anything Please let me know and I will do the same.

Cheers,
Smithb2
(E-Mail Removed)
 
Reply With Quote
 
Member
Join Date: Apr 2006
Posts: 29
 
      31st Jan 2007
As promised, Here is the solution I found to my dilemma:

As you may recall, as with your situation, I was trying to automatically determine, with a macro, how many columns were to be added and insert this info into the sum formula:

Option Explicit
Dim i As Integer

Sub HrsTotal()
i = 0

‘Do loop determines # of columns to store in integer variable (Hrs is the header for the ‘column

Do While ActiveCell.Value <> "Hrs"

ActiveCell.Offset(-1, 0).Select

i = i + 1

Loop

‘Following line uses the # stored in “i” to select cell in which to place sum function

ActiveCell.Offset(Int(i), 0).Select

‘In the following, I simply turn the value stored in “i” from positive to negative, in ‘preparation for sum formula.

i = -(i)

ActiveCell.FormulaR1C1 = "=SUM(R[" & i & "]C:R[-1]C)"

End Sub


The last line contains what I was unable to figure out, How to get the sum formula to accept the variable "i" as a value: " & i & "

Have a great day,
Smithb2
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
R1C1 Formula Paul W Smith Microsoft Excel Programming 2 19th Aug 2009 01:03 PM
Formula R1C1 kay Microsoft Excel Programming 3 4th Dec 2008 05:09 PM
Convert Input String Formula to Number Ken Hudson Microsoft Excel Programming 2 11th Mar 2008 02:26 PM
R1C1 Formula smithb2 Microsoft Excel Programming 1 31st Jan 2007 07:42 PM
Formula VS Formula R1C1 Niek Otten Microsoft Excel Programming 3 10th Jul 2005 03:41 PM


Features
 

Advertising
 

Newsgroups
 


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