+ Reply to Thread
Results 1 to 7 of 7

Code working but on wrong sheet

  1. #1
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,702

    Code working but on wrong sheet

    Hi,

    The code below works however it copies it to the wrong sheet (the sheet you are viewing when the macro is ran).

    I think this is the part i need to amend:
    Please Login or Register  to view this content.
    Is there any way I can select the sheet I want to copy it to e.g.
    =Range(Sheets("macro"."A1")

    This is the code in full

    Please Login or Register  to view this content.
    Last edited by pauldaddyadams; 11-11-2011 at 07:30 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Code working but on wrong sheet

    You need to add the sheet name before that part
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,702

    Re: Code working but on wrong sheet

    How do I do that, I tried this but it didnt work (sheet name is Macro)

    Please Login or Register  to view this content.

  4. #4
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,784

    Re: Code working but on wrong sheet

    You could try:

    Please Login or Register  to view this content.
    Alf

  5. #5
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,702

    Re: Code working but on wrong sheet

    Unfortunatly that didnt work

  6. #6
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    365
    Posts
    1,256

    Re: Code working but on wrong sheet

    Hi Paul,

    Copying to a different sheet with the advanced filter is one of the rare occasions when you have to use the Worksheet.Select method. That is, you must ensure that the target sheet is the active sheet before you call Range.AdvancedFilter.

    Something like this (untested):

    Please Login or Register  to view this content.
    Hope that helps,

    Colin

    RAD Excel Blog

  7. #7
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,702

    Re: Code working but on wrong sheet

    Excellent - that worked!! Thank you!

    I wish i never ever used advanced filter lol

+ 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