Results 1 to 2 of 2

Thread: VBA Code: Copy and Paste Range if requirements met

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    10,457
    Rep Power
    10
    Hi there!

    Welcome here at excelfox.

    The first thing to check is to change …_
    If c = "yes" And Month(Intersect(Rows(c.Row), Range("A1:A5000"))) = Month(Now) Then
    _... to
    If c = "yes" And Month(Intersect(Rows(c.Row), Range("A1:A5000")).Value) = Month(Now) Then

    To explain :
    Most people get in the bad habit of missing that out .Value. ( Even me sometimes Lol!!!!! :-) )

    Using .Value on a range object ( Your Intersect(Rows(c.Row), Range("A1:A5000")) should give you a range object ) ensures that a value is returned rather than the range object. In 99% of the uses of a range object in a code, VBA guesses that you wanted the .Value, so it assumes that and adds it internally. So people get in the habit of missing it out to save a bit of typing.

    _._________________-

    The easiest way to take it further if you need more help would be to upload a reduced data test file:

    Prepare a small, reduced row, test data sample of your file, that is to say the worksheet which you copy from. Change any sensitive/ private/ personal data, or just make data up.
    Show an output/after worksheet which you prepare yourself/ fill in manually. That should show exactly the output that you want the coding to give you , based on your data worksheet
    Choose the data carefully so that it tests all possible scenarios.
    You only need a very small number of rows to develop the coding on: You may have noticed that the coding is usually written to work on the data that is there: The coding usually automatically adjusts to work on any amount of rows. But it is a lot easier to develop coding with a small amount of test data, that is to say a small amount of rows.


    We can then get your current code working and possibly suggest some quicker alternatives, such as one I did recently here:
    http://www.eileenslounge.com/viewtop...=31687#p245219


    Alan


    P.S. it is not obvious the first time around how to upload a file here. Here is some notes on it
    http://www.excelfox.com/forum/showth...age9#post10769
    If that proves difficult , then contact me privately and we will find a way for you to give me a file
    Last edited by DocAElstein; 01-30-2019 at 07:59 PM.
    ….If you are my competitor, I will try all I can to beat you. But if I do, I will not belittle you. I will Salute you, because without you, I am nothing.
    If you are my enemy, we will try to kick the fucking shit out of you…..
    Winston Churchill, 1939
    Save your Forum..._
    KILL A MODERATOR!!

Similar Threads

  1. Copy/Paste Excel Range/Chart into Powerpoint VBA
    By Admin in forum Excel and VBA Tips and Tricks
    Replies: 1
    Last Post: 03-13-2014, 02:59 PM
  2. Replies: 1
    Last Post: 03-11-2014, 06:03 PM
  3. Replies: 8
    Last Post: 10-31-2013, 12:38 AM
  4. Replies: 1
    Last Post: 10-16-2013, 05:06 PM
  5. Trapping Copy To Range Before Copy/Cut Paste
    By Rasm in forum Excel Help
    Replies: 4
    Last Post: 04-07-2011, 07:48 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •