Results 1 to 4 of 4

searching a range within a range

Threaded View

  1. #1
    Registered User
    Join Date
    02-01-2009
    Location
    Winnipeg, Canada
    MS-Off Ver
    Excel 2003
    Posts
    9

    searching a range within a range

    Hi. Me = macro neophite, mostly just record macros and tweak as need be. But need help with this one.

    Trying to enter pay rates into a data sheet when an employee works in a specified department.

    My logic may be off, but what I want to do is this:

    for each cell in A:A
    the cell = employee#
    if (the cell in column D is not null AND the cell in column e is blank) then the cell in column D is the department

    go to sheet to and for each cell in range A:A of sheet 2
    if the active cell = employee and the corresponding cell in column c = dept, then copy the corresponding cell in column D of Sheet 2 and paste it into column E of the first sheet.

    I attached a sample of the data. The actual sheets are hundreds of pages long and will take me a couple days to go through without a macro - so if anyone is in a generous mood, I'd appreciate the help.

    Thanks.

    I know it is really wrong and its embarraising for me to post it, but this where I got so far and decided that I needed help

    Sub Macro2()
    '
    ' Macro2 Macro
    Dim ee
    Dim dept
    Dim x As Range
    Dim y As Range
    
    On Error Resume Next
    
    For Each x In Range("A:A")
    
    Set ee = ActiveCell.Value
    
    If Selection.Offset(0, 3) Is Not Null And Selection.Offset(0, 4) = "" Then Set dept = Selection.Offset(0, 3).Value
        Sheets("Sheet2").Select
        For Each y In Range("A:A")
            If y = ee And Selection.Offset(0, 2) = dept Then Selection.Offset(0, 3).Copy
            Sheets("Sheet1").Select
            Selection.Offset(0, 3).PasteSpecial
        Next
    Next
    End Sub
    Attached Files Attached Files
    Last edited by mr.alexander; 11-29-2010 at 12:29 PM.

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