bsharath
asked on
Excel sheet find for a text and delete the whole row
Hi,
I want to find for a text and delete the whole row in the excel sheet.
Regards
Sharath
I want to find for a text and delete the whole row in the excel sheet.
Regards
Sharath
ASKER
I get this error.
-------------------------- -
Microsoft Visual Basic
-------------------------- -
Compile error:
Syntax error
-------------------------- -
OK Help
-------------------------- -
if cells(i,1) = "whatever you want"
--------------------------
Microsoft Visual Basic
--------------------------
Compile error:
Syntax error
--------------------------
OK Help
--------------------------
if cells(i,1) = "whatever you want"
use cell(i,1).value
ASKER
Can you post the whole edited macro
sub delete()
dim i as long
for i = 1 to 65000
if cells(i,1).value = "whatever you want"
rows(i).select
Selection.Delete Shift:=xlUp
i = i - 1
end if
next i
end sub
dim i as long
for i = 1 to 65000
if cells(i,1).value = "whatever you want"
rows(i).select
Selection.Delete Shift:=xlUp
i = i - 1
end if
next i
end sub
ASKER
This still gives a compile error.
if cells(i,1).value = "whatever you want"
if cells(i,1).value = "whatever you want"
ok got it try this
sub delete()
dim i as long
for i = 1 to 65000
if Sheet1.cells(i,1).value = "whatever you want"
rows(i).select
Selection.Delete Shift:=xlUp
i = i - 1
end if
next i
end sub
sub delete()
dim i as long
for i = 1 to 65000
if Sheet1.cells(i,1).value = "whatever you want"
rows(i).select
Selection.Delete Shift:=xlUp
i = i - 1
end if
next i
end sub
ok got it try this
sorry
sub delete()
dim i as long
for i = 1 to 65000
if Sheet1.cells(i,1).value = "whatever you want"
Sheet1.rows(i).select
Selection.Delete Shift:=xlUp
i = i - 1
end if
next i
end sub
sorry
sub delete()
dim i as long
for i = 1 to 65000
if Sheet1.cells(i,1).value = "whatever you want"
Sheet1.rows(i).select
Selection.Delete Shift:=xlUp
i = i - 1
end if
next i
end sub
ASKER
Still get this error.
-------------------------- -
Microsoft Visual Basic
-------------------------- -
Compile error:
Syntax error
-------------------------- -
OK Help
-------------------------- -
--------------------------
Microsoft Visual Basic
--------------------------
Compile error:
Syntax error
--------------------------
OK Help
--------------------------
ok got it try this
sorry
sorry
sub delete()
dim i as long
for i = 1 to 65000
if Sheet1.cells(i,1).value = "whatever you want" then
Sheet1.rows(i).select
Selection.Delete Shift:=xlUp
i = i - 1
end if
next i
end sub
sorry
sorry
sub delete()
dim i as long
for i = 1 to 65000
if Sheet1.cells(i,1).value = "whatever you want" then
Sheet1.rows(i).select
Selection.Delete Shift:=xlUp
i = i - 1
end if
next i
end sub
I have done some modification pls check
Sub del()
Dim i As Long
x = Application.InputBox("Ente r Value")
For i = 1 To 65000
If Sheet1.Cells(i, 1).Value = Conversion.CStr(x) Then
Sheet1.Rows(i).Select
Selection.delete Shift:=xlUp
i = i - 1
End If
Next i
End Sub
End If
Next i
End Sub
Sub del()
Dim i As Long
x = Application.InputBox("Ente
For i = 1 To 65000
If Sheet1.Cells(i, 1).Value = Conversion.CStr(x) Then
Sheet1.Rows(i).Select
Selection.delete Shift:=xlUp
i = i - 1
End If
Next i
End Sub
End If
Next i
End Sub
ASKER
Hitesh
No error and i dont get a box to enter
Patel i get this.
-------------------------- -
Microsoft Visual Basic
-------------------------- -
Compile error:
Only comments may appear after End Sub, End Function, or End Property
-------------------------- -
OK Help
-------------------------- -
No error and i dont get a box to enter
Patel i get this.
--------------------------
Microsoft Visual Basic
--------------------------
Compile error:
Only comments may appear after End Sub, End Function, or End Property
--------------------------
OK Help
--------------------------
ok check this
Sub del()
Dim i As Long
x = InputBox("Enter Value")
For i = 1 To 65000
If Sheet1.Cells(i, 1).Value = Str(x) Then
Sheet1.Rows(i).Select
Selection.delete Shift:=xlUp
i = i - 1
End If
Next i
End Sub
Sub del()
Dim i As Long
x = InputBox("Enter Value")
For i = 1 To 65000
If Sheet1.Cells(i, 1).Value = Str(x) Then
Sheet1.Rows(i).Select
Selection.delete Shift:=xlUp
i = i - 1
End If
Next i
End Sub
Sub del()
Dim i As Long
x = Application.InputBox("Ente r Value")
For i = 1 To 65000
If Sheet1.Cells(i, 1).Value = Conversion.CStr(x) Then
Sheet1.Rows(i).Select
Selection.delete Shift:=xlUp
i = i - 1
End If
Next i
End Sub
Dim i As Long
x = Application.InputBox("Ente
For i = 1 To 65000
If Sheet1.Cells(i, 1).Value = Conversion.CStr(x) Then
Sheet1.Rows(i).Select
Selection.delete Shift:=xlUp
i = i - 1
End If
Next i
End Sub
ASKER
patel.
I get no errors nor results.
I have this in the excel
Sharath Reddy
ramesh Sasi
When i enter sharath there is no changes.
I get no errors nor results.
I have this in the excel
Sharath Reddy
ramesh Sasi
When i enter sharath there is no changes.
ASKER
Ok got it.I think this works only for numbers....
Can it even search text and perform the same.
Can it even search text and perform the same.
ok try this
Sub del()
Dim i As Long
x = InputBox("Enter Value")
For i = 1 To 65000
If UCase(Sheet1.Cells(i, 1).Value) = UCase(Str(x)) Then
Sheet1.Rows(i).Select
Selection.delete Shift:=xlUp
i = i - 1
End If
Next i
End Sub
Sub del()
Dim i As Long
x = InputBox("Enter Value")
For i = 1 To 65000
If UCase(Sheet1.Cells(i, 1).Value) = UCase(Str(x)) Then
Sheet1.Rows(i).Select
Selection.delete Shift:=xlUp
i = i - 1
End If
Next i
End Sub
ASKER
Some issue in the macro.
The excel restarts and goes to recovery mode.
The excel restarts and goes to recovery mode.
ok try this
Sub del()
Dim i As Long
x = InputBox("Enter Value")
For i = 1 To 65000
If UCase(Sheet1.Cells(i, 1).Value) = UCase(Str(x)) Then
Sheet1.Rows(i).Select
Selection.delete Shift:=xlUp
End If
Next i
End Sub
Sub del()
Dim i As Long
x = InputBox("Enter Value")
For i = 1 To 65000
If UCase(Sheet1.Cells(i, 1).Value) = UCase(Str(x)) Then
Sheet1.Rows(i).Select
Selection.delete Shift:=xlUp
End If
Next i
End Sub
ASKER
The same error. Excel restarting
ok try this
Sub del()
Dim i As Long
x = InputBox("Enter Value")
For i = 1 To Sheet1.UsedRange.Rows.Coun t
If UCase(Sheet1.Cells(i, 1).Value) = UCase(Str(x)) Then
Sheet1.Rows(i).Select
Selection.delete Shift:=xlUp
End If
Next i
End Sub
Sub del()
Dim i As Long
x = InputBox("Enter Value")
For i = 1 To Sheet1.UsedRange.Rows.Coun
If UCase(Sheet1.Cells(i, 1).Value) = UCase(Str(x)) Then
Sheet1.Rows(i).Select
Selection.delete Shift:=xlUp
End If
Next i
End Sub
did this solve the problem?
ASKER
Same problem Excel restarting
i dont understand why, just delete everything and paste the above lines again
ASKER
No same error.Any other way of doing this.
ok try this
Sub deletesearch()
Dim i As Long
x = InputBox("Enter Value")
For i = 1 To Sheet1.UsedRange.Rows.Coun t
If UCase(Sheet1.Cells(i, 1).Value) = UCase(Str(x)) Then
Sheet1.Rows(i).Delete
End If
Next
End Sub
Sub deletesearch()
Dim i As Long
x = InputBox("Enter Value")
For i = 1 To Sheet1.UsedRange.Rows.Coun
If UCase(Sheet1.Cells(i, 1).Value) = UCase(Str(x)) Then
Sheet1.Rows(i).Delete
End If
Next
End Sub
ASKER
Same i get an error and the excel restarts
can you upload the file?
ASKER
ok try this
Sub deletesearch()
Dim i As Long, x As String
x = InputBox("Enter Value")
For i = 1 To Sheet1.UsedRange.Rows.Coun t
If UCase(Sheet1.Cells(i, 1).Value) = UCase(x) Then
Sheet1.Rows(i).Delete
End If
Next
End Sub
Sub deletesearch()
Dim i As Long, x As String
x = InputBox("Enter Value")
For i = 1 To Sheet1.UsedRange.Rows.Coun
If UCase(Sheet1.Cells(i, 1).Value) = UCase(x) Then
Sheet1.Rows(i).Delete
End If
Next
End Sub
ASKER
Ok this is fine.But when the data is in some other colum it does not delete
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
the column number you are searching your text is in 1
sub delete()
dim i as long
for i = 1 to 65000
if cells(i,1) = "whatever you want"
rows(i).select
Selection.Delete Shift:=xlUp
i = i - 1
end if
next i
end sub