03. maj 2004 - 01:35Der er
4 kommentarer og 1 løsning
Find og tæl celler.
Jeg bruger følgende kode til at finde og tælle celler. Problemet er at den finder første og anden dato, men glemmer at få lagt månedens længde til den anden dato den finder. C mangler at blive forlænget med en måned.
Public Sub FindNavne()
Dim A As Variant
For C = 3 To 65000 Sheets("Turnusplan").Select Cells(C, 2).Select If Cells(C, 2) = "" Then GoTo IkkeFlere M = Int(Month(Cells(C, 2))) Y = Int(Year(Cells(C, 2)))
If M = Range("Sm") And Y = Range("så") Then R1 = C K1 = 2 End If
If M = Range("SLM") And Y = Range("SLÅ") Then R2 = C K2 = 15
GoTo IkkeFlere End If
If M = 1 Or M = 3 Or M = 5 Or M = 7 Or M = 8 Or M = 10 Or M = 12 Then C = C + 30 If M = 4 Or M = 6 Or M = 9 Or M = 11 Then C = C + 29 If Y Mod 4 = 0 And M = 2 Then C = C + 28 If Y Mod 4 <> 0 And M = 2 Then C = C + 27
dCount = 0 Application.Volatile For Each rCell In Selection If rCell.Interior.ColorIndex = Sheets("Print , statistik , mødetider").Range("C14").Interior.ColorIndex Then dCount = dCount + 1 End If Next rCell Sheets("Print , statistik , mødetider").Range("F14") = dCount
dCount = 0 Application.Volatile For Each rCell In Selection If rCell.Interior.ColorIndex = Sheets("Print , statistik , mødetider").Range("C22").Interior.ColorIndex Then dCount = dCount + 1 End If Next rCell Sheets("Print , statistik , mødetider").Range("F22") = dCount
'Sheets("Turnusplan").Select 'Cells(C, 2).Select Sheets("Print , statistik , mødetider").Select
For C = 3 To 65000 Sheets("Turnusplan").Select Cells(C, 2).Select If Cells(C, 2) = "" Then GoTo IkkeFlere M = Int(Month(Cells(C, 2))) Y = Int(Year(Cells(C, 2)))
If M = Range("Sm") And Y = Range("så") Then R1 = C K1 = 2 End If
If M = 1 Or M = 3 Or M = 5 Or M = 7 Or M = 8 Or M = 10 Or M = 12 Then C = C + 30 If M = 4 Or M = 6 Or M = 9 Or M = 11 Then C = C + 29 If Y Mod 4 = 0 And M = 2 Then C = C + 28 If Y Mod 4 <> 0 And M = 2 Then C = C + 27
If M = Range("SLM") And Y = Range("SLÅ") Then ' ER FLYTTET R2 = C K2 = 15
dCount = 0 Application.Volatile For Each rCell In Selection If rCell.Interior.ColorIndex = Sheets("Print , statistik , mødetider").Range("C14").Interior.ColorIndex Then dCount = dCount + 1 End If Next rCell Sheets("Print , statistik , mødetider").Range("F14") = dCount
dCount = 0 Application.Volatile For Each rCell In Selection If rCell.Interior.ColorIndex = Sheets("Print , statistik , mødetider").Range("C22").Interior.ColorIndex Then dCount = dCount + 1 End If Next rCell Sheets("Print , statistik , mødetider").Range("F22") = dCount
'Sheets("Turnusplan").Select 'Cells(C, 2).Select Sheets("Print , statistik , mødetider").Select
Har vist glemt at lukke. Fik kun sagt tak. Undskyld ventetiden.
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.