Question : copy cells dynamically in excel

Hey

I have a table with initials in the rows and weeknumbers in the culumn. Beside I have a list with some of the initials and a specific weeknumber - from this list I want to copy the content to the exact positions in the table by pushing a button. My guess is, that vba would be the solution.

I have tried to explain in the attached excel file.

Excel 2007 for windows.

Help :-)

Cheers, Raahaugen
Attachments:
 
my problem
 

Answer : copy cells dynamically in excel

Raahaugen,,

The macro below is in the attached file. Let me know if it does what you want.

Patrick
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
Sub specialmacro()
Dim rng1 As Range
Dim rng2 As Range
Dim celle1 As Range
Dim celle2 As Range
Dim colm As Long

With Sheets("Sheet1")
    Set rng1 = Range(.Cells(12, "Q"), .Cells(.Rows.Count, "Q").End(xlUp))
    Set rng2 = Range(.Cells(12, "C"), .Cells(27, "C"))
End With

For Each celle1 In rng1
    For Each celle2 In rng2
        If celle1 = celle2 Then
            colm = Cells(11, "V").Value
            celle2.Offset(0, colm) = celle1.Offset(0, 1)
        End If
    Next celle2
Next celle1

End Sub
Random Solutions  
 
programming4us programming4us