Results 1 to 3 of 3

Thread: Basic question

  1. #1

    Basic question



    Register for a FREE account, and/
    or Log in to avoid these ads!

    Hi guys,

    I ve got one very basic question. I type the followig code:


    Sub dad()
    Dim ar As Range

    For Each ar In Range("A1:B3")
    If ar > 40 And ar < 200 Then
    ar.Interior.Color = vbYellow
    ar.Copy
    Sheets("sheet2").Range("A1:B3").PasteSpecial

    End If
    Next ar
    End Sub



    What it does is to make all relevant numbers from my table in yellow. However, the second step - it just copies one of them and puts it in sheet2. I want to take all numbers between 40 and 200 from my list and paste them in sheet2..Any ideas??

    Thanks

  2. #2
    Code:
    Sub dad()Dim ar As Range
    
    
        For Each ar In Range("A1:B3")
            If ar > 40 And ar < 200 Then
                ar.Interior.Color = vbYellow
                ar.Copy Sheets("sheet2").Range(ar.Address)
            End If
        Next ar
        
        Application.CutCopyMode = False
    End Sub

  3. #3
    Hey,

    and if I want to paste in the activesheet starting from say A10? What should I do?

    Thanks

Posting Permissions

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