+ Reply to Thread
Results 1 to 10 of 10

Copy in formula linked to variable other workbook

  1. #1
    Forum Contributor
    Join Date
    07-26-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2016 Office 365 ProPlus
    Posts
    822

    Copy in formula linked to variable other workbook

    So this is the issue.
    For my workbook I need data from a workbook from other month.
    So I use VBA to open the other months workbook and then use a formula to get the data I need.
    This works fine for the month in which i recorded the macro.
    But of course I now need to make it variable.

    I tried with this:
    Please Login or Register  to view this content.
    But this still gives me a popup and I have to navigate myself to the workbook.
    So this is not working.

    This is the original formula not made variable:
    Please Login or Register  to view this content.
    Anybody know how to get this to work?

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Copy in formula linked to variable other workbook

    You need to separate the variable and strings of the formula, so instead of "=sumifs[bbwb]asodfn" for example, you need "=sumifs[" & bbwb & "]asodfn"

    For your code:
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    07-26-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2016 Office 365 ProPlus
    Posts
    822

    Re: Copy in formula linked to variable other workbook

    Hmm ok of course because it is a variable.
    However this one is returning me the 'object doesn't support this property or method' error....

  4. #4
    Forum Contributor
    Join Date
    07-26-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2016 Office 365 ProPlus
    Posts
    822

    Re: Copy in formula linked to variable other workbook

    I don't think this ".Activatesheet.Range("E10")" bit of code is correct?
    Did you mean it to be ActiveSheet?
    But that also does not work unfortunately

  5. #5
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Copy in formula linked to variable other workbook

    Please Login or Register  to view this content.
    ?

  6. #6
    Forum Contributor
    Join Date
    07-26-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2016 Office 365 ProPlus
    Posts
    822

    Re: Copy in formula linked to variable other workbook

    Yes thats what I also tried.
    But still an error. It is in the formula.
    It highlights the formula as having an error.

  7. #7
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Copy in formula linked to variable other workbook

    ah right yeah, you've got some A1-style references in there, C7 should be RC7 or R[-3]C[-2], depending what you mean by it.

  8. #8
    Forum Contributor
    Join Date
    07-26-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2016 Office 365 ProPlus
    Posts
    822

    Re: Copy in formula linked to variable other workbook

    Hmm not sure what you mean with that, the macro has been recorded so I would think the sumifs formula would be ok like that.
    But you probably mean because the formula has been made variabel also the formula format changes?

  9. #9
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Copy in formula linked to variable other workbook

    Yeah I was talking rubbish.

    Try changing BBWB to BBWB.name
    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    07-26-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2016 Office 365 ProPlus
    Posts
    822

    Re: Copy in formula linked to variable other workbook

    You're the King
    That nailed it, thanks!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] copy a worksheet to new workbook with filename linked to cell
    By pika in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-22-2013, 07:01 AM
  2. Copy variable range from variable workbook to variable range on current workbook
    By Locster79 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-09-2013, 10:37 AM
  3. Replies: 0
    Last Post: 12-13-2011, 12:15 PM
  4. Linked Cells - Have part of the link be variable or a formula?
    By CVinje in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-23-2009, 06:37 AM
  5. Replies: 1
    Last Post: 10-31-2006, 08:34 AM

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