ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to use Macro to delete this row?? (https://www.excelbanter.com/excel-programming/298967-how-use-macro-delete-row.html)

kamikazi[_2_]

How to use Macro to delete this row??
 
What am I suppose to put this < section to get the row deleted?
I tried writing < Opp.Offset(0, 1).Selection.EntireRow.Delete
but it's not working. Please advise.

Dim shC As Object, shD As Object, Opp As Object, BPRole As Object,
As Long, k As Long

Dim ops As Object

Set shC = Sheets("Results")
Set shD = Sheets("New")
'Name of the spreadsheets

For j = shD.Range("B500").End(xlUp).Row To 1 Step -1
Set Opp = shD.Cells(j, 11)
Set BPRole = shD.Cells(j, 7)
If (Opp = 100000) And (BPRole = "BPA") Then

<

End If
Next

--
Message posted from http://www.ExcelForum.com


Melanie Breden

How to use Macro to delete this row??
 
What am I suppose to put this < section to get the row deleted?
I tried writing < Opp.Offset(0, 1).Selection.EntireRow.Delete
but it's not working. Please advise.

Dim shC As Object, shD As Object, Opp As Object, BPRole As Object, j
As Long, k As Long

Dim ops As Object

Set shC = Sheets("Results")
Set shD = Sheets("New")
'Name of the spreadsheets

For j = shD.Range("B500").End(xlUp).Row To 1 Step -1
Set Opp = shD.Cells(j, 11)
Set BPRole = shD.Cells(j, 7)
If (Opp = 100000) And (BPRole = "BPA") Then

<

End If
Next j


try this:

If (Opp < 100000) And (BPRole < "BPA") Then
shD.Rows(j).Delete
End If

--
Regards
Melanie Breden
- Microsoft MVP für Excel -

http://excel.codebooks.de (Das Excel-VBA Codebook)


kamikazi[_3_]

How to use Macro to delete this row??
 
Awesome! that worked...

Thank you!

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 05:14 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com