Delete Cell value if it contains any text in Excel

oldb

New Member
Joined
Mar 17, 2021
Messages
12
Office Version
  1. 365
Platform
  1. Windows
Hi,

I need to delete cell values if they contain any text on multiple spreadsheets (but not all, every sheet after the 5th one).
Range would be E3 to GW16 on every sheet.

Is there an easy way to do this?
Thanks for your help
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
hi and welcome toe MrExcel
you could have a command button that you click with a short macro behind it
 
Upvote 0
hi and welcome toe MrExcel
you could have a command button that you click with a short macro behind it
Thanks,

any idea what I should put in the macro? really no expert here :)
 
Upvote 0
how are your sheets named. is there an easy way to pick either the ones you do not want to clear or the other way around. once i know the sheets, the macro is only a few lines and you dont really need to know how it works. you can have a button on a sheet that you click and the macro will do its work
 
Upvote 0
I need to delete cell values if they contain any text on multiple spreadsheets (but not all, every sheet after the 5th one).
Range would be E3 to GW16 on every sheet.
Try this with a copy of your workbook.

VBA Code:
Sub Clear_Cell_Values()
  Dim i As Long
  
  For i = 6 To Sheets.Count
    Sheets(i).Range("E3:GW16").ClearContents
  Next i
End Sub
 
Upvote 0
Try this with a copy of your workbook.

VBA Code:
Sub Clear_Cell_Values()
  Dim i As Long
 
  For i = 6 To Sheets.Count
    Sheets(i).Range("E3:GW16").ClearContents
  Next i
End Sub
Hi peter,

this already helped a lot, but it just clears everything. I need it to clear only if there is text and leave it if there are numbers.

Thanks
 
Upvote 0
how are your sheets named. is there an easy way to pick either the ones you do not want to clear or the other way around. once i know the sheets, the macro is only a few lines and you dont really need to know how it works. you can have a button on a sheet that you click and the macro will do its work
Hi diddi,

well there are quite a lot of sheets so I think its easier to tell you the ones to be left out. (They're in japanese btw. and the star is included, don't know if that has any effect)

★登録車種情報
★管理帳票
★管理帳票 (2)
★原紙
★原紙_2枚目

These are the first 5 sheets and I need to clear cells in the range I mentioned in all the sheets that follow, but only if they contain any text not if they have numbers.
Thanks a lot :)
 
Upvote 0
Not sure how it will go with the Japanese characters but try this

VBA Code:
Sub Clear_Text_Values()
  Dim i As Long
  
  On Error Resume Next
  For i = 6 To Sheets.Count
    Sheets(i).Range("E3:GW16").SpecialCells(xlCellTypeConstants, xlTextValues).ClearContents
  Next i
  On Error GoTo 0
End Sub
 
Upvote 0
Solution
Re: "if they contain any text"
What is considered any text?

1234abcd567
or
abcdef
or
ghij klmn 987
or
1234 formatted as text
 
Upvote 0
Not sure how it will go with the Japanese characters but try this

VBA Code:
Sub Clear_Text_Values()
  Dim i As Long
 
  On Error Resume Next
  For i = 6 To Sheets.Count
    Sheets(i).Range("E3:GW16").SpecialCells(xlCellTypeConstants, xlTextValues).ClearContents
  Next i
  On Error GoTo 0
End Sub
Thanks Peter this seems to work perfectly :)
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,688
Members
448,978
Latest member
rrauni

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