Excel Macro - Need Help - Deleting Content of a Cell till the End of Right (Not Row)

svanan

New Member
Joined
Nov 6, 2009
Messages
4
Dear All,

I need help on Excel 2007 Macro , the below coding searches for a string "recvtiming" in a cell as a wildcard and delete it entire row once it founds it in a single active sheet.

Question,
1. How do I manupulate it to search for the same string and upon finding
a) Delete its cell content and all the contents from its right hand of side till its last column which have a value from the same row on all 50 sheets in the workbook.

e.g
a b c d recvtiming 0 1 2 3 4

It should return,
a b c d

====================Start Code ====================
With ActiveSheet

.Select

ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView

.DisplayPageBreaks = False

Firstrow = .UsedRange.Cells(1).Row
Lastrow = .UsedRange.Rows(.UsedRange.Rows.Count).Row

For Lrow = Lastrow To Firstrow Step -1

If Application.CountIf(.Rows(Lrow), "recvtiming") > 0 Then .Rows(Lrow).Delete

Next Lrow

End With

====================End Code ====================
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Deleting Content of a Cell till the End of Right (Not Row)

I have tried the below, it seem not working too,any advice?

<code>
Sub DeleteColumns()

Dim FirstAddx As String
Dim FoundIt As Range
Dim LastCol As Long
Dim What As String
Dim Wks As Worksheet

What = "recvtiming"

For Each Wks In Worksheets
LastCol = Wks.UsedRange.Columns.Count
Set FoundIt = Wks.UsedRange.Find(What, , xlValues, xlWhole, xlByColumns, xlNext, False)
If Not FoundIt Is Nothing Then
FirstAddx = FoundIt.Address
Do
FoundIt(1, LastCol - FoundIt.Column).ClearContents
Set FoundIt = Wks.UsedRange.FindNext(FoundIt)
Loop While Not FoundIt Is Nothing And FoundIt.Address <> FirstAddx
End If
Next Wks

End Sub
</code>
 
Upvote 0

Forum statistics

Threads
1,215,494
Messages
6,125,139
Members
449,207
Latest member
VictorSiwiide

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