I want to use a condition ifto complete the task ClearContents. Please find my code below for this. I wrote below 2 codes, but both of them were unsuccessful.
if
ClearContents
Try first
t = 1 Do While Cells(t, 1) <> "" If Cells(t, 1) <> "=" Then Cells(t, 1).ClearContents End If t = t + 1 Loop
Second attempt
t = 1 Do While Cells(t, 1) <> "" If Cells(t, 1) <> Formula Then Cells(t, 1).ClearContents End If t = t + 1 Loop
Basically, I don’t want to delete cells containing the available formulas, but I want to delete other data.
Write something like this:
If Not Cells(t,1).HasFormula Then End if
This will work. Or try this:
Sub TestMe() If Not Cells(1, 1).HasFormula Then Debug.Print "No Formula" Else Debug.Print "Has Formula" End If End Sub
Here is additional property information .HasFormula:
.HasFormula
https://msdn.microsoft.com/en-us/library/office/ff837123.aspx
, () .
Cells.SpecialCells(xlCellTypeConstants, 23).ClearContents
, .
, Cells Range("A1:A100") Selection.
Cells
Range("A1:A100")
Selection
( Excel Home → Editing → Find and Select → Go to Special. Excel .)
Source: https://habr.com/ru/post/1678771/More articles:ASP.Net Kernel ID Canceled by Using FindByIdAsync - asp.netПравило 3 Отклонение члена по умолчанию в С++ 11 - c++Cannot enter hero using CLI - gitПонимание "ежедневных" и "еженедельных" областей в Unity.Social & Apple GameCenter Leaderboards - c#react-choose how to edit created entries - reactjsSpecial action-select tag editing function - reactjsDownload a file using ASP.NET Core - c #Django Makemessages CommandError ASCII Encoding - pythonDate and time in UTC - how to save them in postgres? - datedask dataframe apply meta - pythonAll Articles