Adjust macro clear rows if

ste33uka

Active Member
Joined
Jan 31, 2020
Messages
430
Office Version
  1. 365
Platform
  1. Windows
Hi could someone please adjust this macro or offer another macro?
The macro clears the row and the 3 rows below if the number1 is found in column Gi
it clears columns A to FX of rows
What i need it to do is clear columns A to FX and columns GZ to JZ
Example gi4 = 1, A4 TO FX7 and GZ4 to JZ7 would clear.
Thanks

VBA Code:
Sub clear_rows ()
Dim Shtname As String

For sht = 1 To 81
Shtname = "" & sht
With Worksheets(Shtname)
inarr = Range(.Cells(1, 191), .Cells(75, 191)) ' load col A1 to A75 into memory
For i = 4 To UBound(inarr, 1)
If inarr(i, 1) = "1" Then
  .Range(.Cells(i, 1), .Cells(i + 3, 180)) = ""
End If
Next i
End With
Next sht
End Sub
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

Marc L

Well-known Member
Joined
Apr 5, 2021
Messages
1,240
Office Version
  1. 2010
Platform
  1. Windows
Hi,​
as you forgot to post an attachment with the before state and the expected result …​
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
62,379
Office Version
  1. 365
Platform
  1. Windows
How about
VBA Code:
If inarr(i, 1) = "1" Then
  .Range(.Cells(i, 1), .Cells(i + 3, 180)) = ""
  .Range(.Cells(i, 208), .Cells(i + 3, 286)) = ""
End If
 
Solution

ste33uka

Active Member
Joined
Jan 31, 2020
Messages
430
Office Version
  1. 365
Platform
  1. Windows
How about
VBA Code:
If inarr(i, 1) = "1" Then
  .Range(.Cells(i, 1), .Cells(i + 3, 180)) = ""
  .Range(.Cells(i, 208), .Cells(i + 3, 286)) = ""
End If
Thanks again fluff, thats what i was looking for,
And thanks for all your help on all my other posts.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
62,379
Office Version
  1. 365
Platform
  1. Windows
You're welcome & thanks for the feedback.
 

Forum statistics

Threads
1,141,284
Messages
5,705,495
Members
421,398
Latest member
Rahat Anwar

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
Top