+ Reply to Thread
Results 1 to 3 of 3

How to insert a variable or formula in a cell definition

  1. #1
    Registered User
    Join Date
    12-03-2008
    Location
    Cambridge, MA
    Posts
    2

    How to insert a variable or formula in a cell definition

    Hi

    I am new to macros... am trying to insert a variable or a formula in a cell definition, e.g., instead of

    Please Login or Register  to view this content.
    which refers to a cell relative the the active cell, have something like this

    Please Login or Register  to view this content.
    where i is a variable rather than a constant (the number of cells in my original, non-log-transformed data). If I try to run this I get a "run time error '1004', Application-defined or object-defined error".

    Below is the code itself
    Thanks
    Daniel

    Please Login or Register  to view this content.
    Last edited by VBA Noob; 12-03-2008 at 05:48 PM.

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,613
    You've tried to embed your variable i, in a string. Separate it out and concatenate, thus:
    Please Login or Register  to view this content.
    Ben Van Johnson

  3. #3
    Registered User
    Join Date
    12-03-2008
    Location
    Cambridge, MA
    Posts
    2
    Thanks...
    I tried separating it out, which works, but now I have a new problem: If I enter i into the formula like that it still remains a relative formula to the starting cell, so that it will go to the starting cell + i and not to i itself. How can I reference a cell in a way that is not relative to the starting cell?

+ 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