Selecteren wanneer aan meerdere voorwaarden wordt voldaan.

Status
Niet open voor verdere reacties.

Jelle2010

Gebruiker
Lid geworden
14 jan 2010
Berichten
43
Beste Experts,

Ik heb de onderstaande code gemaakt(zie ook bijlage). De IF voorwaarde wil ik graag iets uitgebreider zien maar ik weet niet hoe. Graag wil ik hier nog aan toegevoegd hebben dat als(IF) er in kolom D van die rij "AS" voorkomt.

Alvast vriendelijk bedankt voor jullie hulp.

Sub KleurKopiëren()

Dim LastRow As Long
Dim X As Long
Dim r As Range
Dim CopyRow As Integer

ActiveSheet.Unprotect

Application.ScreenUpdating = False

LastRow = Cells.SpecialCells(xlCellTypeLastCell).Row

For Each r In Range("IV1:IV" & LastRow)
If r.Interior.ColorIndex = 4 And r.Value = Empty Then
r.EntireRow.Copy
X = X + 1
Sheets("Blad2").Range("A" & X).PasteSpecial
r.EntireRow.Interior.ColorIndex = 7
r.Value = Date
r.EntireRow.Locked = True
End If
Next

Application.ScreenUpdating = True

ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFiltering:=True, AllowFormattingCells:=True

End Sub
 

Bijlagen

  • Map1.xls
    33,5 KB · Weergaven: 29
Probleem alsnog opgelost. Zie de code hieronder.

Sub KleurKopiëren()

Dim LastRow As Long
Dim X As Long
Dim r As Range
Dim rijnummer As Integer
Dim CopyRow As Integer

ActiveSheet.Unprotect

Application.ScreenUpdating = False

LastRow = Cells.SpecialCells(xlCellTypeLastCell).Row

For Each r In Range("IV1:IV" & LastRow)
rijnummer = r.Row
If r.Interior.ColorIndex = 4 And r.Value = Empty And Range("D" & rijnummer).Value = "D" Then
r.EntireRow.Copy
X = X + 1
Sheets("Blad2").Range("A" & X).PasteSpecial
r.EntireRow.Interior.ColorIndex = 7
r.Value = Date
r.EntireRow.Locked = True
End If
Next

Application.ScreenUpdating = True

ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFiltering:=True, AllowFormattingCells:=True

End Sub



Beste Experts,

Ik heb de onderstaande code gemaakt(zie ook bijlage). De IF voorwaarde wil ik graag iets uitgebreider zien maar ik weet niet hoe. Graag wil ik hier nog aan toegevoegd hebben dat als(IF) er in kolom D van die rij "AS" voorkomt.

Alvast vriendelijk bedankt voor jullie hulp.

Sub KleurKopiëren()

Dim LastRow As Long
Dim X As Long
Dim r As Range
Dim CopyRow As Integer

ActiveSheet.Unprotect

Application.ScreenUpdating = False

LastRow = Cells.SpecialCells(xlCellTypeLastCell).Row

For Each r In Range("IV1:IV" & LastRow)
If r.Interior.ColorIndex = 4 And r.Value = Empty Then
r.EntireRow.Copy
X = X + 1
Sheets("Blad2").Range("A" & X).PasteSpecial
r.EntireRow.Interior.ColorIndex = 7
r.Value = Date
r.EntireRow.Locked = True
End If
Next

Application.ScreenUpdating = True

ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFiltering:=True, AllowFormattingCells:=True

End Sub
 
of

Code:
Sub KleurKopiëren()
  Application.ScreenUpdating = False
  ActiveSheet.Unprotect

  For Each cl In columns(256).specialcells(xlcelltypeblanks)
     If cl.Interior.ColorIndex = 4 And cl.offset(,-251) = "D" Then
        cl.Value = Date
        with cl.entirerow
           .copy Sheets("Blad2").cells(rows.count,1).end(xlup).offset(1)
           .Interior.ColorIndex = 7
           .Locked = True
        end with
     End If
  Next

  ActiveSheet.Protect 
  Application.ScreenUpdating = True
End Sub
 
Laatst bewerkt:
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan