Codes are not working

decent_boy

Board Regular
Joined
Dec 5, 2014
Messages
130
Office Version
  1. 2016
Platform
  1. 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.

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
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Define "not working". Wrong result? Error raised? No result? I stopped reading when I saw two spellings of "Project" so is that the issue? I suspect you're not using Option Explicit either, which ought to reduce your problems if you were using it.
 
Upvote 0

Forum statistics

Threads
1,215,756
Messages
6,126,685
Members
449,329
Latest member
tommyarra

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top