+ Reply to Thread
Results 1 to 11 of 11

How do I refer to "this workbook" rather than the file path?

  1. #1
    Registered User
    Join Date
    05-09-2018
    Location
    Australia
    MS-Off Ver
    Office 365
    Posts
    32

    How do I refer to "this workbook" rather than the file path?

    Hi all,

    I created a simple macro that works exactly as I want but only when I am in the office. It breaks when I am out of the office.
    How do I refer to "this workbook" instead of the file path as highlighted in red below? I am just wanting to refresh and consolidate sources from another sheet.

    Forgive me, I am a newbie at these things!


    Please Login or Register  to view this content.

  2. #2
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    re: How do I refer to "this workbook" rather than the file path?

    Please Login or Register  to view this content.
    See if this works.
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

  3. #3
    Registered User
    Join Date
    05-09-2018
    Location
    Australia
    MS-Off Ver
    Office 365
    Posts
    32

    re: How do I refer to "this workbook" rather than the file path?

    Thanks for your input, I have substituted with the text you offer and I get a "syntax error"

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    re: How do I refer to "this workbook" rather than the file path?

    Hello koska,

    Try this...
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  5. #5
    Registered User
    Join Date
    05-09-2018
    Location
    Australia
    MS-Off Ver
    Office 365
    Posts
    32

    re: How do I refer to "this workbook" rather than the file path?

    Hi Leith,

    What does the code
    Please Login or Register  to view this content.
    refer to?

  6. #6
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    re: How do I refer to "this workbook" rather than the file path?

    Quote Originally Posted by koska View Post
    Thanks for your input, I have substituted with the text you offer and I get a "syntax error"
    Try it like this

    Please Login or Register  to view this content.
    The leading quote mark and ampersand probably threw the error. BTW, you can remove al those 'ScrollRow' lines. Those are just where you were looking for the next thing to select and have no value to the macro. The recorder just picks up every move you make.
    Last edited by JLGWhiz; 05-10-2018 at 07:36 AM.

  7. #7
    Registered User
    Join Date
    05-09-2018
    Location
    Australia
    MS-Off Ver
    Office 365
    Posts
    32

    re: How do I refer to "this workbook" rather than the file path?

    Thanks JLGWhiz

    I think there is still something missing between ThisWorkbook.FullName & "By Location'!R4C2:R1000C3" _

    as I get an error couldn't not find "correctpathtoworkbook.xlsmBY Location". Is it possible it was moved, rename or deleted?

  8. #8
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    re: How do I refer to "this workbook" rather than the file path?

    You require some apostrophes and square brackets
    Please Login or Register  to view this content.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  9. #9
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    re: How do I refer to "this workbook" rather than the file path?

    Quote Originally Posted by xlnitwit View Post
    You require some apostrophes and square brackets
    Please Login or Register  to view this content.
    Yep, that looks like it should produce the same format that was used in the OP.

  10. #10
    Registered User
    Join Date
    05-09-2018
    Location
    Australia
    MS-Off Ver
    Office 365
    Posts
    32

    re: How do I refer to "this workbook" rather than the file path?

    Quote Originally Posted by xlnitwit View Post
    You require some apostrophes and square brackets
    Please Login or Register  to view this content.

    Appreciate it, perfect!

  11. #11
    Registered User
    Join Date
    05-09-2018
    Location
    Australia
    MS-Off Ver
    Office 365
    Posts
    32

    re: How do I refer to "this workbook" rather than the file path?

    Quote Originally Posted by JLGWhiz View Post
    Yep, that looks like it should produce the same format that was used in the OP.
    Thanks for your efforts!

+ 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 from a workbook without using path or file name
    By Frankie_The_Flyer in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 06-11-2017, 05:10 AM
  2. [SOLVED] Refer to Excel workbook by path, based on cell value data
    By cornfedtm in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 12-27-2014, 11:10 PM
  3. Refer Indirectly to File Path
    By Apokolips in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-03-2014, 06:44 PM
  4. Refer Indirectly to File Path
    By Apokolips in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-03-2014, 01:20 AM
  5. Replies: 5
    Last Post: 03-21-2013, 07:34 AM
  6. Find last row in closed workbook using file path name
    By amazingg64 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-27-2012, 09:22 AM
  7. how to set a workbook from a file name and path
    By lvcha.gouqizi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-21-2005, 05:05 PM

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