Jun 04 2019 12:35 AM - edited Jun 04 2019 12:37 AM
Hello. I have a code that I found on the Internet for removing formula from excel blank cells but it works only for one worksheet with a specific name. I was wondering if someone could change it so it will work for several sheets with different names and ranges. For example sheetA range(a1:b20) , sheetB range(a1:e40), sheetC range(a1:n15)
THANKS.
Sub Macro1()
For Each c In Worksheets("your sheet name").Range("your range")
If c.Value = "" Then c.Select: Selection.ClearContents
Next c
End Sub
Jun 04 2019 01:12 AM
Hi, I hope that I have understood the task correctly.
try this..
Sub RemoveFormulasFromEmptyCells()
Dim wkstab As Worksheet
Dim rngCell As Range
For Each wkstab In Worksheets
For Each rngCell In wkstab.UsedRange
If rngCell.HasFormula And rngCell.Value = "" Then
rngCell.ClearContents
End If
Next rngCell
Next wkstab
End Sub
Regards
Bernd
www.vba-Tanker.com - a database full of excel-macros
Jun 04 2019 01:23 AM
Thanks for the response. I tried but it doesn't work. there's an error with this line:
If rngCell.HasFormula And rngCell.Value = "" Then
Jun 04 2019 02:40 AM
could you append your file, please?
Jun 04 2019 03:05 AM
I'm sorry the file doesn't belong to me so I don't have the right. It's weird it works but it shows me error number 13 at the end. But anyway it doesn't solve my problem because when I save the file as tab delimited or CSV there are the sign ; in the blank cells containing formulas.