+ Reply to Thread
Results 1 to 11 of 11

Macro

  1. #1
    Registered User
    Join Date
    09-20-2005
    Posts
    14

    Macro

    Hi,

    Im trying to do a macro that will move data from a number of sheets based on a flag in column W on each sheet.

    Basically if the flag in column W is "YES" then i want it to copy the whole row and append it (if thats possible?) into the sheet 'Journal'

    I have attached a cut down version with only 3 sheets (one of which is the 'Journal' sheet) and only a few rows on each sheet.

    Firstly is this even possible and if so how would i go about it? i know very little about VBA so any help whatsoever would be very much appreciated.

    Thankyou
    Marc
    Attached Files Attached Files

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

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

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

    Free DataBaseForm example

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Your full code to use that Function would be

    Please Login or Register  to view this content.
    Note: rhe UDF (Function) is the work of Aaron Blood)

  4. #4
    Registered User
    Join Date
    09-20-2005
    Posts
    14
    Thanks for your reply RoyUK, i tried using that code last week after looking around on here but couldnt get it to work, i kept getting an error message

    when i posted this thread i made some changes to the spreadsheet to make it easier to understand, but didnt make the changes to the code to reflect it

    ive made the changes you suggested but im now getting a run time error 91

    object variable or with block variable not set

    it seems to have a problem with the line

    Find_Range("Yes", Range("W13:W100")).EntireRow.Select

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Have you still got the Function in there?

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    09-20-2005
    Posts
    14
    missed a line when i copied and pasted it!

    now im getting a compile error, variable not defined for

    firstAddress = c.Address

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Aaron doesn't use Option Explicit, so you need to place

    Please Login or Register  to view this content.
    in the Function or remove Option Explicit.

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    09-20-2005
    Posts
    14
    thanks for your help RoyUK

    im still getting the runtime 91 error though, before i input the Dim firstAddress As String line i was getting the error in my previous post, but since ive inserted this line im getting the 91 error again

    my code at the moment is:

    Please Login or Register  to view this content.

    any ideas?

  9. #9
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    If it isn't finding any Rows it errors. This seems to work

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    09-20-2005
    Posts
    14
    RoyUK That works a treat! - thankyou for all your help, its much appreciated!

  11. #11
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    That's relief(LOL). Glad we worked it out.

+ 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