ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Creating a macro (https://www.excelbanter.com/excel-programming/404002-creating-macro.html)

jc

Creating a macro
 
Hey guys,
I need to create a macro and i've never done this...i think that this is a
simple macro to build, just need a little help...

I need to build a macro that will delete an entire row when a particular
column =zero....Example...

If cell AD5, AD43 and AD 50 equal zero, i want the macro to delete row 5, 43
and 50.

Thanks!!

JLGWhiz

Creating a macro
 
Press Alt + F11 to open the VB editor, If the window is dark, use
InsertModule and then paste the code below into the window. You can run the
code from Excel by clicking ToolsMacroMacrosRun. Make sure this macro is
in the top window of the dialogue box.

Sub delRws()
If Range("AD5") = 0 And Range("AD43") = 0 _
And Range("AD50") = 0 Then
Set delRng = Application.Union(Rows(5), Rows(43), Rows(50))
delRng.EntireRow.Delete
End If
End Sub

"JC" wrote:

Hey guys,
I need to create a macro and i've never done this...i think that this is a
simple macro to build, just need a little help...

I need to build a macro that will delete an entire row when a particular
column =zero....Example...

If cell AD5, AD43 and AD 50 equal zero, i want the macro to delete row 5, 43
and 50.

Thanks!!


jc

Creating a macro
 
JLGWhiz,
Can we make this say that anywhere in Column AD there is a zero, delete that
corresponding row??

"JLGWhiz" wrote:

Press Alt + F11 to open the VB editor, If the window is dark, use
InsertModule and then paste the code below into the window. You can run the
code from Excel by clicking ToolsMacroMacrosRun. Make sure this macro is
in the top window of the dialogue box.

Sub delRws()
If Range("AD5") = 0 And Range("AD43") = 0 _
And Range("AD50") = 0 Then
Set delRng = Application.Union(Rows(5), Rows(43), Rows(50))
delRng.EntireRow.Delete
End If
End Sub

"JC" wrote:

Hey guys,
I need to create a macro and i've never done this...i think that this is a
simple macro to build, just need a little help...

I need to build a macro that will delete an entire row when a particular
column =zero....Example...

If cell AD5, AD43 and AD 50 equal zero, i want the macro to delete row 5, 43
and 50.

Thanks!!


Mike H

Creating a macro
 
Maybe this

Sub delete_Me()
lastrow = Range("AD65536").End(xlUp).Row
For x = lastrow To 1 Step -1
If Cells(x, 30).Value < "" Then
If Cells(x, 30).Value = 0 Then
Rows(x).Delete
End If
End If
Next
End Sub


Mike

"JC" wrote:

JLGWhiz,
Can we make this say that anywhere in Column AD there is a zero, delete that
corresponding row??

"JLGWhiz" wrote:

Press Alt + F11 to open the VB editor, If the window is dark, use
InsertModule and then paste the code below into the window. You can run the
code from Excel by clicking ToolsMacroMacrosRun. Make sure this macro is
in the top window of the dialogue box.

Sub delRws()
If Range("AD5") = 0 And Range("AD43") = 0 _
And Range("AD50") = 0 Then
Set delRng = Application.Union(Rows(5), Rows(43), Rows(50))
delRng.EntireRow.Delete
End If
End Sub

"JC" wrote:

Hey guys,
I need to create a macro and i've never done this...i think that this is a
simple macro to build, just need a little help...

I need to build a macro that will delete an entire row when a particular
column =zero....Example...

If cell AD5, AD43 and AD 50 equal zero, i want the macro to delete row 5, 43
and 50.

Thanks!!


JLGWhiz

Creating a macro
 
Mike's code should do that.

"JC" wrote:

JLGWhiz,
Can we make this say that anywhere in Column AD there is a zero, delete that
corresponding row??

"JLGWhiz" wrote:

Press Alt + F11 to open the VB editor, If the window is dark, use
InsertModule and then paste the code below into the window. You can run the
code from Excel by clicking ToolsMacroMacrosRun. Make sure this macro is
in the top window of the dialogue box.

Sub delRws()
If Range("AD5") = 0 And Range("AD43") = 0 _
And Range("AD50") = 0 Then
Set delRng = Application.Union(Rows(5), Rows(43), Rows(50))
delRng.EntireRow.Delete
End If
End Sub

"JC" wrote:

Hey guys,
I need to create a macro and i've never done this...i think that this is a
simple macro to build, just need a little help...

I need to build a macro that will delete an entire row when a particular
column =zero....Example...

If cell AD5, AD43 and AD 50 equal zero, i want the macro to delete row 5, 43
and 50.

Thanks!!


jc

Creating a macro
 
Thank-You!!!!

"Mike H" wrote:

Maybe this

Sub delete_Me()
lastrow = Range("AD65536").End(xlUp).Row
For x = lastrow To 1 Step -1
If Cells(x, 30).Value < "" Then
If Cells(x, 30).Value = 0 Then
Rows(x).Delete
End If
End If
Next
End Sub


Mike

"JC" wrote:

JLGWhiz,
Can we make this say that anywhere in Column AD there is a zero, delete that
corresponding row??

"JLGWhiz" wrote:

Press Alt + F11 to open the VB editor, If the window is dark, use
InsertModule and then paste the code below into the window. You can run the
code from Excel by clicking ToolsMacroMacrosRun. Make sure this macro is
in the top window of the dialogue box.

Sub delRws()
If Range("AD5") = 0 And Range("AD43") = 0 _
And Range("AD50") = 0 Then
Set delRng = Application.Union(Rows(5), Rows(43), Rows(50))
delRng.EntireRow.Delete
End If
End Sub

"JC" wrote:

Hey guys,
I need to create a macro and i've never done this...i think that this is a
simple macro to build, just need a little help...

I need to build a macro that will delete an entire row when a particular
column =zero....Example...

If cell AD5, AD43 and AD 50 equal zero, i want the macro to delete row 5, 43
and 50.

Thanks!!



All times are GMT +1. The time now is 08:36 AM.

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