Hi All
I am wondering if it is possible to have a bit of VBA code to clear the contents of specific cells when opening a workbook?
Any help greatly appreciated!
Jason
Hi All
I am wondering if it is possible to have a bit of VBA code to clear the contents of specific cells when opening a workbook?
Any help greatly appreciated!
Jason
Yes it is possible. Which cells? The following example is should be placed in "ThisWorkbook" module:You can pick any range of cells that you want.![]()
Private Sub Workbook_Open() Dim ws1 As Worksheet Set ws1 = Worksheets("Sheet1") ws1.Range("A5:G5").Cells.ClearContents End Sub
If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.
---Keep on Coding in the Free World---
Thanks for your reply Mordred, it worked perfectly! I wanted to select more than one range so I changed it to this:
Private Sub Workbook_Open()
Dim ws1 As Worksheet
Set ws1 = Worksheets("Sheet1")
ws1.Range("D4:D5,A9:L9").Cells.ClearContents
End Sub
Thanks again!
No problem jason1970, don't forget to mark this as solved and if you're happy with my reply, click that star at the bottom left. I'd appreciate that!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks