VBA Delete Entire Row if Contains Certain Text

bigmacneb

Board Regular
Joined
Jul 12, 2005
Messages
93
I've searched on here, but every code I put in gives me an error back. Data in column D, If any of the cells contains "Record Only" I need it to delete the entire row.
Thanks
 
max_cali,

If I understand your latest request, then, here is a new macro solution for you to consider.

Sample raw data in the active worksheet:


Excel 2007
ABCDEFG
1TRANSACTION_REF:ABC45678
2SUM OF PAYMENT_AMOUNT:100000
3PAYMENT_CCY:USD
4PAYMENT_VALUE_DATE:21/04/2017
5
6CODEREFCOMPLETE DATETOTALCCYPMT AMOUNTFILE NAME
7N1111111111127/02/20171111USD1111INV55555555.CSV
8N2222222222227/02/20172222USD2222INV66666666.CSV
9TRANSACTION_REF:ABC12345
10SUM OF PAYMENT_AMOUNT:1618.26
11PAYMENT_CCY:USD
12PAYMENT_VALUE_DATE:21/04/2017
13
14CODEREFCOMPLETE DATETOTALCCYPMT AMOUNTFILE NAME
15N33333333333429793333USD3333INV66666666.CSV
16
Sheet1


And, after the new macro:


Excel 2007
ABCDEFG
1ABC456781111111111127/02/20171111USD1111INV55555555.CSV
2ABC456782222222222227/02/20172222USD2222INV66666666.CSV
3ABC1234533333333333429793333USD3333INV66666666.CSV
4
5
6
7
8
9
10
11
12
13
14
15
16
Sheet1


Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

Code:
Sub max_cali_V3()
' hiker95, 04/25/2017, ME300330
Dim lr As Long, r As Range, t As String
Application.ScreenUpdating = False
With ActiveSheet
  lr = .Cells(Rows.Count, 1).End(xlUp).Row
  With .Range("A1:A" & lr)
    .Replace "SUM OF PAYMENT_AMOUNT*", "#N/A", xlWhole, , False
    .Replace "PAYMENT_CCY*", "#N/A", xlWhole, , False
    .Replace "PAYMENT_VALUE_DATE*", "#N/A", xlWhole, , False
    .Replace "CODE", "#N/A", xlWhole, , False
    .Replace "", "#N/A", xlWhole, , False
  End With
  On Error Resume Next
  .Columns("A").SpecialCells(xlConstants, xlErrors).EntireRow.Delete
  On Error GoTo 0
  lr = .Cells(Rows.Count, 1).End(xlUp).Row
  For Each r In .Range("A1:A" & lr)
    If InStr(r, "TRANSACTION_REF:") Then
      t = Right(r, Len(r) - 16)
    ElseIf r = "N" Then
      r = t
    End If
  Next r
  With .Range("A1:A" & lr)
    .Replace "TRANSACTION_REF*", "#N/A", xlWhole, , False
  End With
  On Error Resume Next
  .Columns("A").SpecialCells(xlConstants, xlErrors).EntireRow.Delete
  On Error GoTo 0
  .Columns(1).AutoFit
End With
Application.ScreenUpdating = True
End Sub

Before you use the macro with Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension .xlsm, and, answer the "do you want to enable macros" question as "yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.

Then run the max_cali_V3 macro.
 
Upvote 0

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Code:
Sub max_cali_V2()
' hiker95, 04/24/2017, ME300330
Dim lr As Long
Application.ScreenUpdating = False
With ActiveSheet
  lr = .Cells(Rows.Count, 1).End(xlUp).Row
  With .Range("A1:A" & lr)
    .Replace "TRANSACTION_REF*", "#N/A", xlWhole, , False
    .Replace "SUM OF PAYMENT_AMOUNT*", "#N/A", xlWhole, , False
    .Replace "PAYMENT_CCY*", "#N/A", xlWhole, , False
    .Replace "PAYMENT_VALUE_DATE*", "#N/A", xlWhole, , False
    .Replace "CODE", "#N/A", xlWhole, , False
    .Replace "", "#N/A", xlWhole, , False
  End With
  On Error Resume Next
  .Columns("A").SpecialCells(xlConstants, xlErrors).EntireRow.Delete
  On Error GoTo 0
  .Columns(1).AutoFit
End With
Application.ScreenUpdating = True
End Sub
Here is another way to write your macro...
Code:
[table="width: 500"]
[tr]
	[td]Sub max_cali_V3()
  Dim LastRow As Long
  With ActiveSheet
    LastRow = .Cells.Find("*", , xlValues, , xlRows, xlPrevious).Row
    .Range("B1:B" & LastRow).SpecialCells(xlConstants, xlNumbers).EntireRow.Copy .Cells(LastRow + 1, "A")
    .Rows("1:" & LastRow).Delete
    .Columns(1).AutoFit
  End With
End Sub[/td]
[/tr]
[/table]
 
Last edited:
Upvote 0
Hi hiker95, it's totally perfect, the result is what I expect. By the way, can we adjust the code to automatically input the transaction reference (e.g. ABC45678 in cell A1, ABC12345 in cell A9) to the next columns "file name".
I'm using windows 7, Excel 2010. Thank you for your kind help.

max_cali,

I missed that part, from your reply #158.

Sample raw data in the active worksheet:


Excel 2007
ABCDEFG
1TRANSACTION_REF:ABC45678
2SUM OF PAYMENT_AMOUNT:100000
3PAYMENT_CCY:USD
4PAYMENT_VALUE_DATE:21/04/2017
5
6CODEREFCOMPLETE DATETOTALCCYPMT AMOUNTFILE NAME
7N1111111111127/02/20171111USD1111INV55555555.CSV
8N2222222222227/02/20172222USD2222INV66666666.CSV
9TRANSACTION_REF:ABC12345
10SUM OF PAYMENT_AMOUNT:1618.26
11PAYMENT_CCY:USD
12PAYMENT_VALUE_DATE:21/04/2017
13
14CODEREFCOMPLETE DATETOTALCCYPMT AMOUNTFILE NAME
15N33333333333429793333USD3333INV66666666.CSV
16
Sheet1


And, after the new macro:


Excel 2007
ABCDEFG
1N1111111111127/02/20171111USD1111ABC45678
2N2222222222227/02/20172222USD2222ABC45678
3N33333333333429793333USD3333ABC12345
4
Sheet1




Code:
Sub max_cali_V4()
' hiker95, 04/25/2017, ME300330
Dim lr As Long, r As Range, t As String
Application.ScreenUpdating = False
With ActiveSheet
  lr = .Cells(Rows.Count, 1).End(xlUp).Row
  With .Range("A1:A" & lr)
    .Replace "SUM OF PAYMENT_AMOUNT*", "#N/A", xlWhole, , False
    .Replace "PAYMENT_CCY*", "#N/A", xlWhole, , False
    .Replace "PAYMENT_VALUE_DATE*", "#N/A", xlWhole, , False
    .Replace "CODE", "#N/A", xlWhole, , False
    .Replace "", "#N/A", xlWhole, , False
  End With
  On Error Resume Next
  .Columns("A").SpecialCells(xlConstants, xlErrors).EntireRow.Delete
  On Error GoTo 0
  lr = .Cells(Rows.Count, 1).End(xlUp).Row
  For Each r In .Range("A1:A" & lr)
    If InStr(r, "TRANSACTION_REF:") Then
      t = Right(r, Len(r) - 16)
    ElseIf r = "N" Then
      r.Offset(, 6) = t
    End If
  Next r
  With .Range("A1:A" & lr)
    .Replace "TRANSACTION_REF*", "#N/A", xlWhole, , False
  End With
  On Error Resume Next
  .Columns("A").SpecialCells(xlConstants, xlErrors).EntireRow.Delete
  On Error GoTo 0
  .Columns("A:G").AutoFit
End With
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Hi hiker95 & Rick, both codes work really well. Honestly, I'm currently not able to tell what's the difference between the two codes or the advantages of each :stickouttounge: Thank you all for your kind help.
 
Upvote 0
max_cali,

Thanks for the feedback.

You are very welcome. Glad we could help.

And, come back anytime.
 
Upvote 0
Hi hiker95, it's totally perfect, the result is what I expect. By the way, can we adjust the code to automatically input the transaction reference (e.g. ABC45678 in cell A1, ABC12345 in cell A9) to the next columns "file name".
I'm using windows 7, Excel 2010. Thank you for your kind help.
max_cali,
I missed that part, from your reply #158.
Code:
Sub max_cali_V4()
' hiker95, 04/25/2017, ME300330
Dim lr As Long, r As Range, t As String
Application.ScreenUpdating = False
With ActiveSheet
  lr = .Cells(Rows.Count, 1).End(xlUp).Row
  With .Range("A1:A" & lr)
    .Replace "SUM OF PAYMENT_AMOUNT*", "#N/A", xlWhole, , False
    .Replace "PAYMENT_CCY*", "#N/A", xlWhole, , False
    .Replace "PAYMENT_VALUE_DATE*", "#N/A", xlWhole, , False
    .Replace "CODE", "#N/A", xlWhole, , False
    .Replace "", "#N/A", xlWhole, , False
  End With
  On Error Resume Next
  .Columns("A").SpecialCells(xlConstants, xlErrors).EntireRow.Delete
  On Error GoTo 0
  lr = .Cells(Rows.Count, 1).End(xlUp).Row
  For Each r In .Range("A1:A" & lr)
    If InStr(r, "TRANSACTION_REF:") Then
      t = Right(r, Len(r) - 16)
    ElseIf r = "N" Then
      r.Offset(, 6) = t
    End If
  Next r
  With .Range("A1:A" & lr)
    .Replace "TRANSACTION_REF*", "#N/A", xlWhole, , False
  End With
  On Error Resume Next
  .Columns("A").SpecialCells(xlConstants, xlErrors).EntireRow.Delete
  On Error GoTo 0
  .Columns("A:G").AutoFit
End With
Application.ScreenUpdating = True
End Sub
Here is how I would modify the code I posted in Message #162 to do this...
Code:
[table="width: 500"]
[tr]
	[td]Sub max_cali_V3revised()
  Dim X As Long, LastRow As Long, LastCol As Long, TRANS As Range, REFs As Range
  LastRow = Cells.Find("*", , xlValues, , xlRows, xlPrevious).Row
  LastCol = Cells.Find("*", , xlValues, , xlColumns, xlPrevious).Column
  Application.ScreenUpdating = False
  With Range("B1:B" & LastRow)
    .Value = Evaluate(Replace("IF(LEFT(@,11)=""TRANSACTION"",RIGHT(@,8),IF(@=""N""," & .Address & ",""""))", "@", .Offset(, -1).Address))
    Set TRANS = .SpecialCells(xlConstants, xlTextValues)
    Set REFs = .SpecialCells(xlConstants, xlNumbers)
    For X = 1 To REFs.Areas.Count
      Intersect(REFs.Areas(X).EntireRow, Columns(LastCol + 1)) = TRANS.Areas(X)(1).Value
    Next
    .SpecialCells(xlConstants, xlNumbers).EntireRow.Copy Cells(LastRow + 1, "A")
  End With
  Rows("1:" & LastRow).Delete
  Columns("A").AutoFit
  Application.ScreenUpdating = True
End Sub[/td]
[/tr]
[/table]
 
Last edited:
Upvote 0
Hi dears, i need to modify the code above so that:
+ The first row (only first row for easy reference) after combination will be:

Excel 2010 32 bit[TABLE="class: head"]
<tbody>[TR="bgcolor: #888888"]
[TH][/TH]
[TH]
A
[/TH]
[TH]
B
[/TH]
[TH]
C
[/TH]
[TH]
D
[/TH]
[TH]
E
[/TH]
[TH]
F
[/TH]
[TH]
G
[/TH]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
1
[/TD]
[TD="bgcolor: #FFFFFF"]CODE[/TD]
[TD="bgcolor: #FFFFFF"]REF[/TD]
[TD="bgcolor: #FFFFFF"]COMPLETE DATE[/TD]
[TD="bgcolor: #FFFFFF"]TOTAL[/TD]
[TD="bgcolor: #FFFFFF"]CCY[/TD]
[TD="bgcolor: #FFFFFF"]PMT AMOUNT[/TD]
[TD="bgcolor: #FFFFFF"]TRANSACTION REF[/TD]
[/TR]
</tbody>[/TABLE]

+ Replace the File name in column G by respective Transaction ref in A1
+ Add few more columns right after column G: Column H: CCY (input from cell A3); Column I (input from cell A2); Column J (input from cell A4)...
+ There will be a blank row (would be perfect if it's formatted in light blue) between each transaction

The raw data is still the same (i make minor adjustment to show clear difference between two transactions):

Excel 2010 32 bit
[TABLE="class: head"]
<tbody>[TR="bgcolor: #888888"]
[TH][/TH]
[TH]
A
[/TH]
[TH]
B
[/TH]
[TH]
C
[/TH]
[TH]
D
[/TH]
[TH]
E
[/TH]
[TH]
F
[/TH]
[TH]
G
[/TH]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
1
[/TD]
[TD="bgcolor: #FFFFFF"]TRANSACTION_REF:ABC45678[/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
2
[/TD]
[TD="bgcolor: #FFFFFF"]SUM OF PAYMENT_AMOUNT:100000[/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
3
[/TD]
[TD="bgcolor: #FFFFFF"]PAYMENT_CCY:USD[/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
4
[/TD]
[TD="bgcolor: #FFFFFF"]PAYMENT_VALUE_DATE:21/04/2017[/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
5
[/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
6
[/TD]
[TD="bgcolor: #FFFFFF"]CODE[/TD]
[TD="bgcolor: #FFFFFF"]REF[/TD]
[TD="bgcolor: #FFFFFF"]COMPLETE DATE[/TD]
[TD="bgcolor: #FFFFFF"]TOTAL[/TD]
[TD="bgcolor: #FFFFFF"]CCY[/TD]
[TD="bgcolor: #FFFFFF"]PMT AMOUNT[/TD]
[TD="bgcolor: #FFFFFF"]FILE NAME[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
7
[/TD]
[TD="bgcolor: #FFFFFF"]N[/TD]
[TD="bgcolor: #FFFFFF"]
11111111111
[/TD]
[TD="bgcolor: #FFFFFF"]27/02/2017[/TD]
[TD="bgcolor: #FFFFFF"]
1111
[/TD]
[TD="bgcolor: #FFFFFF"]USD[/TD]
[TD="bgcolor: #FFFFFF"]
1111
[/TD]
[TD="bgcolor: #FFFFFF"]INV55555555.CSV[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
8
[/TD]
[TD="bgcolor: #FFFFFF"]N[/TD]
[TD="bgcolor: #FFFFFF"]
22222222222
[/TD]
[TD="bgcolor: #FFFFFF"]27/02/2017[/TD]
[TD="bgcolor: #FFFFFF"]
2222
[/TD]
[TD="bgcolor: #FFFFFF"]USD[/TD]
[TD="bgcolor: #FFFFFF"]
2222
[/TD]
[TD="bgcolor: #FFFFFF"]INV66666666.CSV[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
9
[/TD]
[TD="bgcolor: #FFFFFF"]TRANSACTION_REF:ABC12345[/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
10
[/TD]
[TD="bgcolor: #FFFFFF"]SUM OF PAYMENT_AMOUNT:1618.26[/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
11
[/TD]
[TD="bgcolor: #FFFFFF"]PAYMENT_CCY:EUR[/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
12
[/TD]
[TD="bgcolor: #FFFFFF"]PAYMENT_VALUE_DATE:25/04/2017[/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
13
[/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
14
[/TD]
[TD="bgcolor: #FFFFFF"]CODE[/TD]
[TD="bgcolor: #FFFFFF"]REF[/TD]
[TD="bgcolor: #FFFFFF"]COMPLETE DATE[/TD]
[TD="bgcolor: #FFFFFF"]TOTAL[/TD]
[TD="bgcolor: #FFFFFF"]CCY[/TD]
[TD="bgcolor: #FFFFFF"]PMT AMOUNT[/TD]
[TD="bgcolor: #FFFFFF"]FILE NAME[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
15
[/TD]
[TD="bgcolor: #FFFFFF"]N[/TD]
[TD="bgcolor: #FFFFFF"]
33333333333
[/TD]
[TD="bgcolor: #FFFFFF"]
42979
[/TD]
[TD="bgcolor: #FFFFFF"]
3333
[/TD]
[TD="bgcolor: #FFFFFF"]USD[/TD]
[TD="bgcolor: #FFFFFF"]
3333
[/TD]
[TD="bgcolor: #FFFFFF"]INV66666666.CSV[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
16
[/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[TD="bgcolor: #FFFFFF"][/TD]
[/TR]
</tbody>[/TABLE]


The result will be:

Excel 2010 32 bit
[TABLE="class: head"]
<tbody>[TR="bgcolor: #888888"]
[TH][/TH]
[TH]
A
[/TH]
[TH]
B
[/TH]
[TH]
C
[/TH]
[TH]
D
[/TH]
[TH]
E
[/TH]
[TH]
F
[/TH]
[TH]
G
[/TH]
[TH]
H
[/TH]
[TH]
I
[/TH]
[TH]
J
[/TH]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
1
[/TD]
[TD="bgcolor: #FFFFFF"]CODE[/TD]
[TD="bgcolor: #FFFFFF"]REF[/TD]
[TD="bgcolor: #FFFFFF"]COMPLETE DATE[/TD]
[TD="bgcolor: #FFFFFF"]TOTAL[/TD]
[TD="bgcolor: #FFFFFF"]CCY[/TD]
[TD="bgcolor: #FFFFFF"]PMT AMOUNT[/TD]
[TD="bgcolor: #FFFFFF"]TRANSACTION REF[/TD]
[TD="bgcolor: #FFFFFF"]
CCY
[/TD]
[TD="bgcolor: #FFFFFF"]PAYMENT AMOUNT[/TD]
[TD="bgcolor: #FFFFFF"]VALUE DATE[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
2
[/TD]
[TD="bgcolor: #FFFFFF"]N[/TD]
[TD="bgcolor: #FFFFFF"]
11111111111
[/TD]
[TD="bgcolor: #FFFFFF"]27/02/2017[/TD]
[TD="bgcolor: #FFFFFF"]
1111
[/TD]
[TD="bgcolor: #FFFFFF"]USD[/TD]
[TD="bgcolor: #FFFFFF"]
1111
[/TD]
[TD="bgcolor: #FFFFFF"]ABC45678[/TD]
[TD="bgcolor: #FFFFFF"]
USD
[/TD]
[TD]
10000​
[/TD]
[TD]21/04/2017[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
3
[/TD]
[TD="bgcolor: #FFFFFF"]N[/TD]
[TD="bgcolor: #FFFFFF"]
22222222222
[/TD]
[TD="bgcolor: #FFFFFF"]27/02/2017[/TD]
[TD="bgcolor: #FFFFFF"]
2222
[/TD]
[TD="bgcolor: #FFFFFF"]USD[/TD]
[TD="bgcolor: #FFFFFF"]
2222
[/TD]
[TD="bgcolor: #FFFFFF"]ABC45678[/TD]
[TD="bgcolor: #FFFFFF"]
USD
[/TD]
[TD]
10000​
[/TD]
[TD]21/04/2017[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
4
[/TD]
[TD="bgcolor: #DDEBF7"][/TD]
[TD="bgcolor: #DDEBF7"][/TD]
[TD="bgcolor: #DDEBF7"][/TD]
[TD="bgcolor: #DDEBF7"][/TD]
[TD="bgcolor: #DDEBF7"][/TD]
[TD="bgcolor: #DDEBF7"][/TD]
[TD="bgcolor: #DDEBF7"][/TD]
[TD="bgcolor: #DDEBF7"][/TD]
[TD="bgcolor: #DDEBF7"][/TD]
[TD="bgcolor: #DDEBF7"][/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
5
[/TD]
[TD="bgcolor: #FFFFFF"]N[/TD]
[TD="bgcolor: #FFFFFF"]
33333333333
[/TD]
[TD="bgcolor: #FFFFFF"]
42979
[/TD]
[TD="bgcolor: #FFFFFF"]
3333
[/TD]
[TD="bgcolor: #FFFFFF"]USD[/TD]
[TD="bgcolor: #FFFFFF"]
3333
[/TD]
[TD="bgcolor: #FFFFFF"]ABC12345[/TD]
[TD]
EUR​
[/TD]
[TD]
1618.26​
[/TD]
[TD]25/04/2017[/TD]
[/TR]
</tbody>[/TABLE]

Any help would be very much appreciated.
 
Last edited:
Upvote 0
Mark,

I came across your code, modified it slightly (below) but i'm receiving a Run-time error '13' Type Mismatch message. What have I done incorrectly?

Sub DeleteRowWithContents()
'========================================================================
' DELETES ALL ROWS FROM A2 DOWNWARDS WITH THE WORDs "Record Only" IN COLUMN D
'========================================================================
Last = Cells(Rows.Count, "E").End(xlUp).Row
For i = Last To 1 Step -1
If (Cells(i, "E").Value) = "#N/A" Then
'Cells(i, "A").EntireRow.ClearContents ' USE THIS TO CLEAR CONTENTS BUT NOT DELETE ROW
Cells(i, "A").EntireRow.Delete
End If
Next i
End Sub
 
Upvote 0
I came across your code, modified it slightly (below) but i'm receiving a Run-time error '13' Type Mismatch message. What have I done incorrectly?

If (Cells(i, "E").Value) = "#N/A" Then
You cannot test for an error cell that way, try it this way...

If Cells(i, "E").Value = CVErr(xlErrNA) Then
 
Upvote 0

Forum statistics

Threads
1,223,275
Messages
6,171,121
Members
452,381
Latest member
Nova88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top