View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Johannes B. Johannes B. is offline
external usenet poster
 
Posts: 1
Default VB-macro - Copy from another workook

I have this code to copy certain values from one sheet to another:

Private Sub worksheet_activate()
Dim rAogB As Range
Set rAogB = Worksheets("Sheet2").Range("aogb")
Dim skrivA As Range
Set skrivA = Range("A1")
Dim j As Integer
j = 1
For i = 1 To rAogB.Height
If rAogB(i, 2) = "a" Then
skrivA(j, 1) = rAogB(i, 1)
skrivA(j, 2) = rAogB(i, 2)
j = j + 1
End If
Next i
End Sub

But now my values are located in another workbook (and not only in another
worksheet). How do I refeer to this workbook?