Hello,
I have a excel file with more then 10 sheets..Some of the sheets contains this word in some random cells" #DIV/0! " I want a macro which can find it in every sheet except parent sheet and can remove it.
Regards
Hello,
I have a excel file with more then 10 sheets..Some of the sheets contains this word in some random cells" #DIV/0! " I want a macro which can find it in every sheet except parent sheet and can remove it.
Regards
Maybe:
![]()
Sub Haidar123aabbzz() Dim ws As Worksheet Dim rcell As Range For Each ws In ActiveWorkbook.Worksheets ws.Activate If ws.Name <> "Parent Sheet's Name Goes Here" Then For Each rcell In ws.UsedRange If rcell.Text = "#DIV/0!" Then rcell.Value = "" Next rcell End If Next ws End Sub
Parent sheet name can be different in each excel file can u make it more general.![]()
I have modified it
![]()
Sub Haidar123aabbzz() Dim ws As Worksheet Dim rcell As Range For Each ws In ActiveWorkbook.Worksheets ws.Activate If ws.Index <> 1 Then For Each rcell In ws.UsedRange If rcell.Text = "#DIV/0!" Then rcell.Value = "" Next rcell End If Next ws End Sub
But it is very time consuming because it gives new empty value to it...May be if it is deleted it will be good..
can u modify to delete it.![]()
Deleting was more time consumingso the last one I modify is best
![]()
Sub Haidar123aabbzz() Dim ws As Worksheet Dim rcell As Range For Each ws In ActiveWorkbook.Worksheets ws.Activate If ws.Index <> 1 Then For Each rcell In ws.UsedRange If rcell.Text = "#DIV/0!" Then rcell.Value = "" Next rcell End If Next ws End Sub
Thanks
![]()
You're welcome. I didn't know what you meant by Parent worksheet? Now it's clearer you meant Sheet1 or the first sheet. I've never heard it refered to as the parent worksheet before? I'm glad you got your problem solved. Please mark this thread as solved in accordance with Forum Rule No. 9.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks