WCM - Das österreichische Computer Magazin Forenübersicht
 

Zurück   WCM Forum > Rat & Tat > Software

Software Rat & Tat bei Softwareproblemen

Microsoft KARRIERECAMPUS

 
 
Themen-Optionen Ansicht
Alt 03.03.2005, 21:15   #3
jak
Inventar
 
Registriert seit: 13.06.2001
Beiträge: 1.830


Standard

Bei der Beschreibung kann ich mir das schon Vorstellen ...

Also kurzgefaßt:

Du hast Kunden und Mitarbeiter und willst die Summe aller Stunden pro Kunde?

Ich würde das mit VBA machen:
Code:
'Function lookForName
'Determines if a customer's name is already found in the
'second (control) sheet; returns the row number if it is found
'else the negative number of the last row
'The Function terminates if it finds two empty lines
Function lookForName(cName As String) As Integer
  Dim colNum, rowNum As Integer
  Dim custName As String
  colNum = 1
  rowNum = 1
  Do
    custName = Worksheets("Kontrolle").Cells(rowNum, colNum).Value
    If (custName = cName) Then
      lookForName = rowNum
      Exit Function
    End If
    rowNum = rowNum + 1
    'the next line is to be sure that the function only terminates after
    'two empty lines
    If (custName = "") Then custName = Worksheets("Kontrolle").Cells(rowNum, colNum).Value
  Loop Until custName = ""
  lookForName = (rowNum - 1) * -1
End Function


Sub Makro1()
  Dim name, temp As String 'name of the customer, temp
  Dim wTime As Single 'The worktime
  Dim i, j, targetRow As Integer 'count variables
  Dim colStart, rowStart, nextCol, timeCol, checkCol As Integer
  colStart = 3 'start value for colums (=C)
  rowStart = 2 'start value for rows (=2)
  nextCol = 3 'the distance to the next column
  timeCol = -1 'the relative position of the
    'Column where the time is stored
  checkCol = 1 'The relative position of the column
    ' in which to check if a Column counts
    ' 1 or "true" means count, everything else means don't count
  i = colStart
  j = rowStart
  Do
    Do
      name = Worksheets("Dienstplan").Cells(j, i).Value
      temp = Worksheets("Dienstplan").Cells(j, i + checkCol).Value
      If ((temp = "1") Or (temp = "true")) Then
        wTime = Worksheets("Dienstplan").Cells(j, i + timeCol).Value
        targetRow = lookForName((name))
        If (targetRow > 0) Then 'Name already exists
          Dim c As Object
          Set c = Worksheets("Kontrolle").Cells(targetRow, 2)
          c.Value = c.Value + wTime
        Else 'Name not found--> create new cells
          targetRow = targetRow * -1
          Worksheets("Kontrolle").Cells(targetRow, 1).Value = name
          Worksheets("Kontrolle").Cells(targetRow, 2).Value = wTime
        End If
      End If
      j = j + 1
      If (name = "") Then name = Worksheets("Dienstplan").Cells(j, i).Value
    Loop Until (name = "")
    i = i + nextCol
    j = rowStart
    name = Worksheets("Dienstplan").Cells(j, i).Value
  Loop Until (name = "")

End Sub
Der Code ist sicher nicht die effizienteste Art es zu lösen, aber es ist zumindest mal eine Lösung

Jak
____________________________________
Join the DNRC | Godwin\'s Law (thx@stona)
Documentation is like sex: If it\'s good, it\'s very, very good. If it\'s bad, it\'s better than nothing.
\"In theory, theory and practice are the same. In practice, they are not\" (Lawrence Berra)
jak ist offline   Mit Zitat antworten
 


Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)
 

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.

Gehe zu


Alle Zeitangaben in WEZ +2. Es ist jetzt 13:29 Uhr.


Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Forum SEO by Zoints
© 2009 FSL Verlag