ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Variable with no Value inside Macro Equation?? (https://www.excelbanter.com/excel-programming/330667-variable-no-value-inside-macro-equation.html)

TEAM

Variable with no Value inside Macro Equation??
 

I am trying to setup a code that dumps data from one sheet to another.
The user inputs the row number of the data, then the data in that row
is tranferred. How do I get VB/Excel to recognize the value of my
variable in the equations?? My code below is not working.


Code:
--------------------
Sub TransferInfo()

RNum = InputBox("Enter the row number of the new unit")
StationName = "='Master List (Base)'! & RNum & 'E'"

Sheets("DataInput").Select
Range("C5").Select
ActiveCell.FormulaR1C1 = "='Master List (Base)'! & StationName"
--------------------



Thanks.


--
TEAM
------------------------------------------------------------------------
TEAM's Profile: http://www.excelforum.com/member.php...o&userid=22810
View this thread: http://www.excelforum.com/showthread...hreadid=375720


MrShorty[_3_]

Variable with no Value inside Macro Equation??
 

It looks to me like you have incorrectly R1c1 notation with standard
notation. r1c1 notation doesn't refer to a column using the letter 'E'
I also don't think you've got Stationname concatenated the way it
should be. stationname also duplicates the worksheet reference that is
in place when you assign the formula.

HTH


--
MrShorty
------------------------------------------------------------------------
MrShorty's Profile: http://www.excelforum.com/member.php...o&userid=22181
View this thread: http://www.excelforum.com/showthread...hreadid=375720


KL

Variable with no Value inside Macro Equation??
 
Hi,

Not sure if I get it correctly, but try this:

Sub TransferInfo()
RNum = InputBox("Enter the row number of the new unit")
StationName = "='Master List (Base)'!E" & RNum
Sheets("DataInput").Range("C5").Formula = StationName
End Sub

or even

Sub TransferInfo()
RNum = InputBox("Enter the row number of the new unit")
StationName = "='Master List (Base)'!E" & RNum
Sheets("DataInput").Range("C5") = Evaluate(StationName)
End Sub

Regards,
KL



"TEAM" wrote in message
...

I am trying to setup a code that dumps data from one sheet to another.
The user inputs the row number of the data, then the data in that row
is tranferred. How do I get VB/Excel to recognize the value of my
variable in the equations?? My code below is not working.


Code:
--------------------
Sub TransferInfo()

RNum = InputBox("Enter the row number of the new unit")
StationName = "='Master List (Base)'! & RNum & 'E'"

Sheets("DataInput").Select
Range("C5").Select
ActiveCell.FormulaR1C1 = "='Master List (Base)'! & StationName"
--------------------



Thanks.


--
TEAM
------------------------------------------------------------------------
TEAM's Profile:
http://www.excelforum.com/member.php...o&userid=22810
View this thread: http://www.excelforum.com/showthread...hreadid=375720





All times are GMT +1. The time now is 06:56 AM.

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