+ Reply to Thread
Results 1 to 9 of 9

Macro for...If column C equals "Cherry", copy and paste it to column E

  1. #1
    Valued Forum Contributor
    Join Date
    04-11-2006
    MS-Off Ver
    2007
    Posts
    438

    Macro for...If column C equals "Cherry", copy and paste it to column E

    Hi all,

    I need a Macro that does this...

    If column C equals "Cherry", copy and paste it to column E

    I'm sure this is an easy one for you guys. I am slowly getting the hang of this code stuff.

    Thanks
    Last edited by duugg; 03-24-2009 at 05:34 PM.

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988

    Re: Macro for...If column C equals "Cherry", copy and paste it to column E

    Why not adapt the code you got in your last post

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Valued Forum Contributor
    Join Date
    04-11-2006
    MS-Off Ver
    2007
    Posts
    438

    Re: Macro for...If column C equals "Cherry", copy and paste it to column E

    Hi Noob,

    I thought about it but the code would be different I think. Let me explain why...

    Grape Code says...
    If grape is in column C, copy column D and paste into E.

    Cherry Code says
    If cherry is in column C, copy that same column (C) and paste into E.

    I thought about it for a moment and did try to change to code, but it didn't work. Here's what I did...

    Please Login or Register  to view this content.
    What did I do wrong?

    Thanks

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988

    Re: Macro for...If column C equals "Cherry", copy and paste it to column E

    You didn't tell it what you want the offset to be

    e.g

    Change
    Please Login or Register  to view this content.
    to

    Please Login or Register  to view this content.
    also you should only go down to the last cell instead of the whole Column to increase speed

    e.g

    Please Login or Register  to view this content.
    VBA Noob

  5. #5
    Valued Forum Contributor
    Join Date
    04-11-2006
    MS-Off Ver
    2007
    Posts
    438

    Re: Macro for...If column C equals "Cherry", copy and paste it to column E

    Noob,

    As always, great code! After thinking about both codes (Cherry and Grape) for a moment, I realized that what I truly want is a bit of a variance to this.

    If this should be a new thread, my apologies but I think it's relevant to this thread.

    I think what I really want Excel to do is this...

    1. IF a row in column E has data in it, leave that whole row alone.
    1. IF a row in column E has NO data in it, find the first column in the same row that has data in a cell (right to left...ie first D, then C, then B) then copy and paste the contents of that cell into column E.

    Thanks

  6. #6
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988

    Re: Macro for...If column C equals "Cherry", copy and paste it to column E

    Maybe

    Please Login or Register  to view this content.
    It assumes data always in Col D, B or C and you want to go to last cel in Col E instead of whole column

    VBA Noob

  7. #7
    Valued Forum Contributor
    Join Date
    04-11-2006
    MS-Off Ver
    2007
    Posts
    438

    Re: Macro for...If column C equals "Cherry", copy and paste it to column E

    Hmm,

    It worked, but only until it found the first occurrence of data in column E, then the macro stopped. There are some rows that have data in column E, then some that don't, then do...etc.

    Is there a way to keep this macro running and do a check down to the last row with data in it?

    For example, column F will always have the bottom-most data in it (along with other columns but I'll use column F as the example).

    Thanks

  8. #8
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988

    Re: Macro for...If column C equals "Cherry", copy and paste it to column E

    Try changing the letter

    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    VBA Noob

  9. #9
    Valued Forum Contributor
    Join Date
    04-11-2006
    MS-Off Ver
    2007
    Posts
    438

    Re: Macro for...If column C equals "Cherry", copy and paste it to column E

    Worked awesome!

    Thanks!

+ 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