Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

The Offset function

Status
Not open for further replies.

balistikb

Technical User
Nov 12, 2002
177
US
Can anyone help me? I am using the Offset function to insert a value into a cell. I am trying to insert "1,2" into a cell but keep getting "False" into that cell instead. Does anyone know why?
Here is the code:
Public Sub DeleteDuplicateRows()
'
' This macro deletes duplicate rows in the selection. Duplicates are
' counted in the COLUMN of the active cell.

Dim Col As Integer
Dim r As Long
Dim C As Range
Dim N As Long
Dim V As Variant
Dim Rng As Range
Dim oFound As Range

On Error GoTo EndMacro
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

Col = ActiveCell.Column

If Selection.Rows.Count > 1 Then
Set Rng = Selection
Else
Set Rng = ActiveSheet.UsedRange.Rows
End If

N = 0
For r = Rng.Rows.Count To 1 Step -1
V = Rng.Cells(r, 1).Value
If Application.WorksheetFunction.CountIf(Rng.Columns(1), V) > 1 Then
Rng.Rows(r).EntireRow.Delete
Set oFound = Rng.Find(V, , xlValues, xlWhole)
oFound.Offset(0, -20) = oFound.Offset(0, -20) = "1,2"
Set oFound = Nothing

N = N + 1
End If
Next r

EndMacro:
 
oFound.Offset(0, -20) = oFound.Offset(0, -20) = "1,2"
is causing the problem - you need:
oFound.Offset(0, -20) = "1,2"
Rgds
Geoff
"Some cause happiness wherever they go; others whenever they go."
-Oscar Wilde
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top