09. december 2011 - 21:02
#3
Så skulle denne makro kunne klare det:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("h17:h19, h32:h34, v20:v22, v29:v31")) Is Nothing Then
x = ""
For y = 17 To 21
If Cells(y, 8) >= 120 Then
x = x & " " & Cells(y, 8)
End If
Next
For y = 32 To 34
If Cells(y, 8) >= 120 Then
x = x & " " & Cells(y, 8)
End If
Next
For y = 20 To 22
If Cells(y, 22) >= 120 Then
x = x & " " & Cells(y, 22)
End If
Next
For y = 29 To 31
If Cells(y, 22) >= 120 Then
x = x & " " & Cells(y, 22)
End If
Next
Cells(7, 17) = x
End If
End Sub
10. december 2011 - 17:53
#7
Du får lige hele koden:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("h17:i40, v17:w40")) Is Nothing Then
'entry of data into Q7
x = ""
For y = 17 To 19
If Cells(y, 8) >= 120 Then
x = x & " " & Cells(y, 8)
End If
Next
For y = 32 To 34
If Cells(y, 8) >= 120 Then
x = x & " " & Cells(y, 8)
End If
Next
For y = 20 To 22
If Cells(y, 22) >= 120 Then
x = x & " " & Cells(y, 22)
End If
Next
For y = 29 To 31
If Cells(y, 22) >= 120 Then
x = x & " " & Cells(y, 22)
End If
Next
Cells(7, 17) = x
'entry of data into Q8
x = ""
For y = 20 To 22
If Cells(y, 8) >= 120 Then
x = x & " " & Cells(y, 8)
End If
Next
For y = 29 To 31
If Cells(y, 8) >= 120 Then
x = x & " " & Cells(y, 8)
End If
Next
For y = 23 To 25
If Cells(y, 22) >= 120 Then
x = x & " " & Cells(y, 22)
End If
Next
For y = 32 To 34
If Cells(y, 22) >= 120 Then
x = x & " " & Cells(y, 22)
End If
Next
Cells(8, 17) = x
'entry of data into Q9
x = ""
For y = 23 To 25
If Cells(y, 8) >= 120 Then
x = x & " " & Cells(y, 8)
End If
Next
For y = 38 To 40
If Cells(y, 8) >= 120 Then
x = x & " " & Cells(y, 8)
End If
Next
For y = 26 To 28
If Cells(y, 22) >= 120 Then
x = x & " " & Cells(y, 22)
End If
Next
For y = 35 To 37
If Cells(y, 22) >= 120 Then
x = x & " " & Cells(y, 22)
End If
Next
Cells(9, 17) = x
'entry of data into Q10
x = ""
For y = 26 To 28
If Cells(y, 8) >= 120 Then
x = x & " " & Cells(y, 8)
End If
Next
For y = 35 To 37
If Cells(y, 8) >= 120 Then
x = x & " " & Cells(y, 8)
End If
Next
For y = 17 To 19
If Cells(y, 22) >= 120 Then
x = x & " " & Cells(y, 22)
End If
Next
For y = 38 To 40
If Cells(y, 22) >= 120 Then
x = x & " " & Cells(y, 22)
End If
Next
Cells(10, 17) = x
'entry of data into Q11
x = ""
For y = 20 To 22
If Cells(y, 9) >= 120 Then
x = x & " " & Cells(y, 9)
End If
Next
For y = 35 To 37
If Cells(y, 9) >= 120 Then
x = x & " " & Cells(y, 9)
End If
Next
For y = 20 To 22
If Cells(y, 23) >= 120 Then
x = x & " " & Cells(y, 23)
End If
Next
For y = 35 To 37
If Cells(y, 23) >= 120 Then
x = x & " " & Cells(y, 23)
End If
Next
Cells(11, 17) = x
'entry of data into Q12
x = ""
For y = 17 To 19
If Cells(y, 9) >= 120 Then
x = x & " " & Cells(y, 9)
End If
Next
For y = 29 To 31
If Cells(y, 9) >= 120 Then
x = x & " " & Cells(y, 9)
End If
Next
For y = 26 To 28
If Cells(y, 23) >= 120 Then
x = x & " " & Cells(y, 23)
End If
Next
For y = 38 To 40
If Cells(y, 23) >= 120 Then
x = x & " " & Cells(y, 23)
End If
Next
Cells(12, 17) = x
'entry of data into Q13
x = ""
For y = 26 To 28
If Cells(y, 9) >= 120 Then
x = x & " " & Cells(y, 9)
End If
Next
For y = 38 To 40
If Cells(y, 9) >= 120 Then
x = x & " " & Cells(y, 9)
End If
Next
For y = 23 To 25
If Cells(y, 23) >= 120 Then
x = x & " " & Cells(y, 23)
End If
Next
For y = 29 To 31
If Cells(y, 23) >= 120 Then
x = x & " " & Cells(y, 23)
End If
Next
Cells(13, 17) = x
'entry of data into Q14
x = ""
For y = 23 To 25
If Cells(y, 9) >= 120 Then
x = x & " " & Cells(y, 9)
End If
Next
For y = 32 To 34
If Cells(y, 9) >= 120 Then
x = x & " " & Cells(y, 9)
End If
Next
For y = 17 To 19
If Cells(y, 23) >= 120 Then
x = x & " " & Cells(y, 23)
End If
Next
For y = 32 To 34
If Cells(y, 23) >= 120 Then
x = x & " " & Cells(y, 23)
End If
Next
Cells(14, 17) = x
End If
End Sub