+ Reply to Thread
Results 1 to 7 of 7

Copy cell if certain demands are met [Solved]

Hybrid View

  1. #1
    Registered User
    Join Date
    08-06-2012
    Location
    Norwat
    MS-Off Ver
    Excel 2010
    Posts
    8

    Copy cell if certain demands are met [Solved]

    Hi,

    I have an excel sheet with a lot of values. Sometimes I wan't to extract some of these cell values. I've tried to create a macro that copies the cell value(it could be text) if the cell background color is yellow and paste is into another cell. After that I want the values to be plotted into a scatter chart.

    this is what I got, but it doesen't work...:

    For Each cell In Worksheets("Sheet1").Range("A1:A30").Cells
    
    If cell.Interior.ColorIndex = 6 Then
    ActiveCell.Copy
    Range("M1").Select
    ActiveSheet.Paste
    
    End If
    
    Next
    
    
    End Sub
    Could anyone please help me?


    Tor from Norway
    Last edited by Cutter; 08-06-2012 at 10:33 AM. Reason: Added code tags

  2. #2
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Copy cell if certain demands are met

    I'm no expert in VBA, but i noticed you don't begin your macro with a sub, e.g.
    Sub copie_on_color()
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  3. #3
    Registered User
    Join Date
    08-06-2012
    Location
    Norwat
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Copy cell if certain demands are met

    Yes sorry, I just forgot to copy it. That's not the problem.

  4. #4
    Forum Contributor
    Join Date
    11-26-2011
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    159

    Re: Copy cell if certain demands are met

    Hi something like this,
    Sub yelcoping()
    Dim rng As Range
    Set rng = Sheets("sheet1").Range("A1:A30")
    For Each ccell In rng
    rrow = Sheets("sheet1").Cells(Rows.Count, "M").End(xlUp).Row
    If ccell.Interior.ColorIndex = 6 Then
    ccell.Copy Cells(rrow + 1, "M")
    End If
    Next ccell
    
    End Sub

  5. #5
    Registered User
    Join Date
    08-06-2012
    Location
    Norwat
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Copy cell if certain demands are met

    Perfect!! Thank you very much!

  6. #6
    Forum Contributor
    Join Date
    11-26-2011
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    159

    Re: Copy cell if certain demands are met

    Quote Originally Posted by paljako View Post
    Perfect!! Thank you very much!
    Glad I helped someone. Please marked as solved. & don't forget to click on STAR

  7. #7
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Copy cell if certain demands are met [Solved]

    @ paljako

    Welcome to the forum.

    Please notice that code tags have been added to your post. The forum rules require them so please keep that in mind and add them yourself whenever showing code in any of your future posts. To see instructions for applying them, click on the Forum Rules button at top of the page and read Rule #3.
    Thanks.

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. I'll do that for you now but please keep in mind for your future threads that Rule #9 requires you to do that yourself. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

    Also, as a new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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