+ Reply to Thread
Results 1 to 3 of 3

Variable with no Value inside Macro Equation??

  1. #1
    Registered User
    Join Date
    04-29-2005
    Posts
    45

    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.

    Please Login or Register  to view this content.

    Thanks.

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,819
    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

  3. #3
    KL
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    >
    > 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
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1