decent_boy
Board Regular
- Joined
- Dec 5, 2014
- Messages
- 130
- Office Version
- 2016
- Platform
- Windows
Hi,
I have written following code to find each value in sheets and sum all match string values but these codes are not proving me required result
can somebody please help.
I have written following code to find each value in sheets and sum all match string values but these codes are not proving me required result
can somebody please help.
VBA Code:
Public Sub EventMacro()
Dim ws As Worksheet
Dim rng4, rng1 As Range
Dim s As String
Dim myRange As Range
Worksheets("Projectt").Activate
'On Error Resume Next
Set rng4 = Worksheets("Project").Range("A7:A8")
For Each c In rng4
If c.Value <> "Differenz / Bedarf" And c.Value <> "" And c.Value <> "KALULIERTE STUNDEN" Then
s = c.Value
c.Offset(0, 1).Value = 0
c.Offset(0, 2).Value = 0
c.Offset(0, 3).Value = 0
c.Offset(0, 4).Value = 0
c.Offset(0, 5).Value = 0
c.Offset(0, 6).Value = 0
c.Offset(0, 7).Value = 0
c.Offset(0, 8).Value = 0
c.Offset(0, 9).Value = 0
c.Offset(0, 10).Value = 0
c.Offset(0, 11).Value = 0
c.Offset(0, 12).Value = 0
For Each ws In Worksheets
If ws.Name <> "Data" And ws.Name <> "Project" Then
'ws.Activate
'MsgBox ws.Name
Set myRange = ws.Range("A8:A13")
With myRange
Set rng1 = .Find(What:=s, LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Not rng1 Is Nothing Then
c.Offset(0, 1).Value = c.Offset(0, 1).Value + rng1.Offset(0, 1).Value
c.Offset(0, 2).Value = c.Offset(0, 2).Value + rng1.Offset(0, 2).Value
c.Offset(0, 3).Value = c.Offset(0, 3).Value + rng1.Offset(0, 3).Value
c.Offset(0, 4).Value = c.Offset(0, 4).Value + rng1.Offset(0, 4).Value
c.Offset(0, 5).Value = c.Offset(0, 5).Value + rng1.Offset(0, 5).Value
c.Offset(0, 6).Value = c.Offset(0, 6).Value + rng1.Offset(0, 6).Value
c.Offset(0, 7).Value = c.Offset(0, 7).Value + rng1.Offset(0, 7).Value
c.Offset(0, 8).Value = c.Offset(0, 8).Value + rng1.Offset(0, 8).Value
c.Offset(0, 9).Value = c.Offset(0, 9).Value + rng1.Offset(0, 9).Value
c.Offset(0, 10).Value = c.Offset(0, 10).Value + rng1.Offset(0, 10).Value
c.Offset(0, 11).Value = c.Offset(0, 11).Value + rng1.Offset(0, 11).Value
c.Offset(0, 12).Value = c.Offset(0, 12).Value + rng1.Offset(0, 12).Value
End If
End With
End If
Next ws
End If
Worksheets("Projektubersicht").Activate
Next c
End Sub