Thread: VBA troubles
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Louis Louis is offline
external usenet poster
 
Posts: 31
Default VBA troubles

I have a code (see below)
i would like to be able to check in column D if there is already the same
document number,if the code find the same number it should delete the row and
paste the new values. This VBA is not working could someone help me?

Thanks

Sub Macro1()

Dim Wk As Workbook, Rep


Set Wk = Workbooks.Open(Filename:="C:\Databasere_validierun g.xls")



Windows("excel base.xls").Activate
Range("B1:B80").Select
Selection.Copy
Windows("Databasere_validierung.xls").Activate
Cells(Rows.Count, 1).End(xlUp).Offset(1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=True
If Application.CountIf([D:D], Cells(Rows.Count, 3).End(xlUp)) 1
Then
Var = Cells(Rows.Count, 3).End(xlUp)
For i = Cells(Rows.Count, 3).End(xlUp).Row - 1 To 1 Step -1
If Cells(i, 3) = Var Then Rows(i).Delete
Next i
End If
'Wk.Close True'
End Sub