No video

Automatically Clear Contents of Worksheet without Clearing Formulas

  Рет қаралды 47,261

Dinesh Kumar Takyar

Dinesh Kumar Takyar

Күн бұрын

How to automatically clear contents of a worksheet without deleting the formulas using VBA. Below is the complete VBA code:
Option Explicit
Sub removeMyConstants()
Dim myConstants As Range
Dim cel As Range
Set myConstants = Sheet1.Range("A1:F4").SpecialCells(xlCellTypeConstants)
On Error Resume Next
myConstants.ClearContents
For Each cel In Range("A1:F4")
If cel.Value = 0 Then
cel.NumberFormat = "#;#;"
End If
Next
End Sub

Пікірлер: 37
@ashrafabdallaattyaelfeky2639
@ashrafabdallaattyaelfeky2639 5 жыл бұрын
Sir Thank you for all the wonderful videos and your smooth explanation. We wish you more success and progress
@Exceltrainingvideos
@Exceltrainingvideos 4 жыл бұрын
Appreciate your motivational feedback.
@Whatisnottaken
@Whatisnottaken Жыл бұрын
Thank you very much for the tuition. Everything worked fine. The formulas are still there except for the accounting format. Your help is appreciated .
@alexandergonzalojimenezcas3984
@alexandergonzalojimenezcas3984 4 жыл бұрын
You're my hero Dinish greetings from Peru, excelent
@Exceltrainingvideos
@Exceltrainingvideos 4 жыл бұрын
Thank you!
@ohitaodu-thomas8521
@ohitaodu-thomas8521 3 жыл бұрын
Thank you so much ! This formula just saved me a whole lot of work. I previously was using codes that took away the formulas but this just did the trick!
@Exceltrainingvideos
@Exceltrainingvideos 3 жыл бұрын
Fantastic! Please share with your friends too.
@leon436100
@leon436100 4 жыл бұрын
You are amazing human being. The code is so concise!
@Exceltrainingvideos
@Exceltrainingvideos 4 жыл бұрын
Glad the VBA code helped. Please share with your buddies.
@leon436100
@leon436100 4 жыл бұрын
Dinesh Kumar Takyar sure!
@sandeepkumar-cx4or
@sandeepkumar-cx4or 5 жыл бұрын
Wondorfull sir ji your are great i am big fan of you
@Exceltrainingvideos
@Exceltrainingvideos 4 жыл бұрын
Thank you for the feedback - great motivation.
@arvindgupta5457
@arvindgupta5457 3 жыл бұрын
Grt dinesh ji
@Exceltrainingvideos
@Exceltrainingvideos 3 жыл бұрын
Thanks.
@lekkiezdasd
@lekkiezdasd 9 ай бұрын
hi sir, your video is very helpful, I have a question though, how I remove the contents or the formulas if not 0 the #;#; only works on 0. thank you
@latoyamartin3698
@latoyamartin3698 Жыл бұрын
Thank you sir. Is there a way to clear the value of the cells and keep the formulas with a dollar sign and dash?
@AbdullaKhizamworld
@AbdullaKhizamworld 5 жыл бұрын
Sir I need to do the raw data sheet from Receipt. to receipt their is two form. one is directly paying cash at the time buying it and another is different format form which is credit settlement receipt. so when ever any kind of payment received we get automatic rawdata with sequence order of all the details in the form. thanks and hope I will get some kind idea or how it is used. thanks 😊
@Exceltrainingvideos
@Exceltrainingvideos 4 жыл бұрын
Query not clear.
@AbdullaKhizamworld
@AbdullaKhizamworld 4 жыл бұрын
@@Exceltrainingvideos Let's say I have a invoice. when ever I create new invoice all the detail like product sold and qty and amount is saved on same workbook but different sheet plus invoice need to be saves as word in folder and also I can send those invoices via mail as PDF to the relevant client.
@AbdullaKhizamworld
@AbdullaKhizamworld 4 жыл бұрын
@@Exceltrainingvideos Sir could you please help me on this? I have give explain below.
@ashwinisg7012
@ashwinisg7012 Жыл бұрын
Sir, How to clear the data once the macro is completed it's activity?
@danemcleod7667
@danemcleod7667 4 жыл бұрын
hi how do I clear a data base of events list every year between April 28 and April 30th it should prompt the user if they want to clear data to start the new year if the user answer is "Yes" then vba clear data base and set the prompt for the next up coming year, if "No" then when the sheet activate it should continue prompt to clear data until user clear that by April 30th
@Exceltrainingvideos
@Exceltrainingvideos 4 жыл бұрын
These two links will guide: www.exceltrainingvideos.com/quick-and-easy-inventory/ www.exceltrainingvideos.com/generate-report-based-on-dates/ Or search for more VBA tutorials on the topic: www.exceltrainingvideos.com
@dijanaduran
@dijanaduran 3 жыл бұрын
Hello, I have one question. How can I clear contents without deleting also format of every cell? Now I can't delete formulas but shape of cell is also lost when i press button Clean with your code. Thank you for your help!
@Exceltrainingvideos
@Exceltrainingvideos 3 жыл бұрын
Make a copy of your file and try, for example: Range("A1").ClearContents
@viribusgym2216
@viribusgym2216 5 жыл бұрын
thank you for this video. if there is no problem i have one more question. my searchable drop down list don't work every time, it work in specific cells and other cells doesn't work, Same Data Validation work in a sheet but if i used in other sheet doesn't work. There is any solution to make a searchable and clickable drop down list using vba or other methods ? Thank you
@Exceltrainingvideos
@Exceltrainingvideos 4 жыл бұрын
Can you share your code?
@suchitagaikwad755
@suchitagaikwad755 4 жыл бұрын
Hello sir , I have written same code but it not clearing cell data and while running the code it does not show any error. Please answer
@Exceltrainingvideos
@Exceltrainingvideos 4 жыл бұрын
The VBA code is shared in the description. Please check again.
@nvcken
@nvcken 2 жыл бұрын
that cool, how can work without clearing Data validation (dropdown) as well?
@Exceltrainingvideos
@Exceltrainingvideos 2 жыл бұрын
Good question! Range("A1:B3").ClearContents Range A1 has data validation and the other cells have some data.
@anshulgupta3735
@anshulgupta3735 4 жыл бұрын
Hello Sir, Can I use name of the named range instead of cell range in the range arugment?
@Exceltrainingvideos
@Exceltrainingvideos 4 жыл бұрын
Yes.
@anshulgupta3735
@anshulgupta3735 4 жыл бұрын
@@Exceltrainingvideos Thank you sir. I tried and it worked. :)
@ganeshbatcha577
@ganeshbatcha577 2 жыл бұрын
Sir in mobile app wt can we do
@sayedyaqub2326
@sayedyaqub2326 3 жыл бұрын
How to Clear contains only without clearing format?
@Exceltrainingvideos
@Exceltrainingvideos 3 жыл бұрын
Let's say we have formatted text in Range A1: Range("A1").ClearContents The above code will clear the contents without clearing the formats. We can now enter data into range A1. It will have the earlier formatting.
나랑 아빠가 아이스크림 먹을 때
00:15
진영민yeongmin
Рет қаралды 14 МЛН
طردت النملة من المنزل😡 ماذا فعل؟🥲
00:25
Cool Tool SHORTS Arabic
Рет қаралды 32 МЛН
Prank vs Prank #shorts
00:28
Mr DegrEE
Рет қаралды 13 МЛН
Automatically Protect Workbook with Password
11:38
Dinesh Kumar Takyar
Рет қаралды 8 М.
Google Sheets - Clear Contents, Keep Formulas
8:15
Learn Google Sheets & Excel Spreadsheets
Рет қаралды 97 М.
Excel VBA - How to Run Macro when Cell Changes
7:37
Essential Excel
Рет қаралды 39 М.
Run VBA Code on Protected Worksheet
13:31
Dinesh Kumar Takyar
Рет қаралды 90 М.
Macro to combine data from Multiple Excel Worksheets
4:59
Ajay Anand
Рет қаралды 8 М.