+ Reply to Thread
Results 1 to 5 of 5

Replace filename with variable in "Activecell.FormulaR1C1=" expression

  1. #1
    Registered User
    Join Date
    02-27-2009
    Location
    Perth, W.Australia
    MS-Off Ver
    W. Australia
    Posts
    2

    Replace filename with variable in "Activecell.FormulaR1C1=" expression

    I am new to Excel VBA so excuse me if I am asking a silly question. I have recorded a macro which contains several lines of code like this one:

    Please Login or Register  to view this content.
    I would like to replace the filename "OCR 14-02-09.xls" with a variable. I have tried several different combos of brackets and quotes but always get an error message. Is this possible?

    Thanks
    pommyb
    Last edited by pommyb; 03-04-2009 at 02:13 AM. Reason: Solved

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Replace filename with variable in "Activecell.FormulaR1C1=" expression

    pommyb,

    first please edit your last post and adjust your closing CODE tag to [*/CODE*] without asterisks

    to then answer your Q

    Please Login or Register  to view this content.
    Though this formula doesn't make much sense given you're referencing a 2 column range D38:E38 ... you should be looking to "do" something with it... SUM / COUNT etc...

  3. #3
    Registered User
    Join Date
    02-27-2009
    Location
    Perth, W.Australia
    MS-Off Ver
    W. Australia
    Posts
    2

    Re: Replace filename with variable in "Activecell.FormulaR1C1=" expression

    Donkeyote,

    Thanks, your solution worked just fine. With regard to your last comment, I recorded that part of the macro.

    Regards

    pommyb

  4. #4
    Registered User
    Join Date
    03-03-2009
    Location
    Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    53

    Re: Replace filename with variable in "Activecell.FormulaR1C1=" expression

    Does anyone know why THIS DOESN'T work?

    Please Login or Register  to view this content.
    I just want the filename (closed file) that it counts cells from to be a variable... why is this so difficult?

  5. #5
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Replace filename with variable in "Activecell.FormulaR1C1=" expression

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread.
    Audere est facere

+ 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