+ Reply to Thread
Results 1 to 5 of 5

defining location in VBA

  1. #1
    Registered User
    Join Date
    06-07-2015
    Location
    United Kingdom
    MS-Off Ver
    2010
    Posts
    38

    defining location in VBA

    wb.ActiveSheet.Range("C4").Value

    I don't want this to copy from the active sheet. I want it to copy from a sheet named "secondsheet" for the purpose of testing.

    However, when I change this, my macro will open the second sheet but then it will stop rather than complete the rest of the code.

    I'm confused as to why this is and would appreciate help.

    Thanks! andy.

    wb.secondsheet.Range("C4").Value <--- this is what I changed it to .

  2. #2
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: defining location in VBA

    Please Login or Register  to view this content.
    insert what the secondsheet is actually called

    otherwise you can use
    which will give the sheet next (to the right) to Activesheet
    Please Login or Register  to view this content.
    this will give to the left
    Please Login or Register  to view this content.
    however...if either left or right is the last sheet of the workbook...it will give an error
    Last edited by humdingaling; 06-16-2015 at 03:10 AM.
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Registered User
    Join Date
    06-07-2015
    Location
    United Kingdom
    MS-Off Ver
    2010
    Posts
    38

    Re: defining location in VBA

    Second sheet is named second sheet. but it can be called test sheet to save confusion.

    The sheet in question doesn't actually exist yet I'm just testing to try and get this to work.

    BUT, although it opens the correct sheet. the macro stalls on the first workbook on that sheet and does not carry out the rest of the tasks.

  4. #4
    Registered User
    Join Date
    06-07-2015
    Location
    United Kingdom
    MS-Off Ver
    2010
    Posts
    38

    Re: defining location in VBA

    Thanks mate, I've used your format and all is good!

  5. #5
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: defining location in VBA

    not a problem

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. 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. Moving *.xlsx from current location including Sub Folders to another location
    By mvinay in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-02-2014, 03:55 AM
  2. Code that works in one location but not another location. (AdvancedFilter excel function)
    By 111StepsAhead in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-29-2013, 02:18 PM
  3. [SOLVED] [Help]macro to open file browser, to select a location, and save the location to a cell
    By zhuleijia in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-06-2013, 09:56 AM
  4. Replies: 1
    Last Post: 10-31-2012, 11:19 AM
  5. Defining Save Location in Print PDF Macro
    By omarq in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-16-2010, 06:31 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