Here is a VBA code that will create a border around cells that have text or a value in them:
Sub AddBorders()
Dim cell As Range
For Each cell In ActiveSheet.UsedRange
If cell.Value <> "" Then 'if the cell has text or a value
cell.BorderAround xlContinuous 'add a border around the cell
End If
Next cell
End Sub
To use this code, open the Visual Basic Editor (VBE) by pressing Alt + F11 in Excel. Then, insert a new module and copy and paste the code into the module. Press F5 to run the code and it will add borders around cells that have text or a value in them.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-03-15 11:00:00 +0000
Seen: 12 times
Last updated: Aug 09 '21
Can Visual Basic be used to code the Grep command?
How can I use Excel VBA to transfer information from an Oracle table to an Excel worksheet?
How do ListBox and Item Values work in Visual Basic 2010?
Is it possible to utilize both Office Script and VBA macros within a single workbook?
How to split an Excel file with a single column containing many records?
How can I use VBA to bring a csv file into MSAccess?
How to use VBA to make a Gantt chart that includes timestamps for day, hour, and minute?
How can new worksheets be automatically generated and saved according to the date?