+ Reply to Thread
Results 1 to 4 of 4

Problem with macro intended to copy cells to a different worksheet based on cell value

  1. #1
    Registered User
    Join Date
    08-07-2013
    Location
    Wellington, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    6

    Problem with macro intended to copy cells to a different worksheet based on cell value

    Hi there,

    Below is part of a macro that I've partly written and partly based off other threads/advice provided here.

    It's intention is to identify which row has one of 18 possible values in it's 'H' column and then copy colums A:H of that row into the range A86:H86 in a seperate spreadsheet. A subsequent part of the macro then copies A86:H86 to another part of the spreadsheet, but that is tested and working fine, so I've left it out for the sake of brevity.

    The issue I am having is with the line "Then Range(Intersect(Rows(i), Range("A:H"))).Copy Sheets("Lists & Formulas").Range("A86:H86"). When the macro runs it returns an error 'Run-time error '1004': Method 'Range' of object '_Global' failed.

    Please Login or Register  to view this content.
    Last edited by Crangiopharengoma; 08-15-2013 at 03:06 AM.

  2. #2
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Problem with macro intended to copy cells to a different worksheet based on cell value

    You can only use "Then" in an IF statement, like: If 1 < 5 Then Your code does not do that. Try removing the Then and see what happens.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,659

    Re: Problem with macro intended to copy cells to a different worksheet based on cell value

    Quote Originally Posted by Crangiopharengoma View Post
    It's intention is to identify which row has one of 18 possible values in it's 'H' column and then copy colums A:H of that row into the range A86:H86 in a seperate spreadsheet.
    Try something like this...

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  4. #4
    Registered User
    Join Date
    08-07-2013
    Location
    Wellington, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Problem with macro intended to copy cells to a different worksheet based on cell value

    That worked perfectly. Thank you very much Alphafrog.

+ 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] Help with Macro to Copy/Paste cells to different worksheet based on Value
    By BehrBrew in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 11-25-2013, 06:41 AM
  2. [SOLVED] Copy specific cells based on one word in the cell, to a different worksheet
    By Lfaulst1 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-30-2013, 05:26 PM
  3. Macro causing Excel to freeze - intended to hide cells with zero value
    By ParkingExcel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-26-2012, 02:11 AM
  4. [SOLVED] Macro to copy certain cells to new worksheet based on cell value
    By mmctague in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-28-2012, 10:54 AM
  5. Macro Problem, copy range of cells based on criteria
    By Ang12345 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-22-2010, 05:10 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