Forum Discussion
Excel
Aug 05, 2021Iron Contributor
VBA code for blank cells
Hello Everyone, I am trying to fill all the blank cells with "UNASSIGNED CUSTOMER" string. The problem i am facing is specifying the range of the loop that i want to run. Since I want to make this ...
- Aug 05, 2021
It returns the range containing all blank cells in the range specified before SpecialCells, in this code the used range of the active sheet.
See Range.SpecialCells method (Excel) and XlCellType enumeration (Excel)
HansVogelaar
Aug 05, 2021MVP
You can't just write some lines of code in a module; you should create a macro or a function.
Try this:
Sub FillTheBlanks()
ActiveSheet.UsedRange.SpecialCells(xlCellTypeBlanks).Value = "UNASSIGNED CUSTOMER"
End Sub
Excel
Aug 05, 2021Iron Contributor
Sir, What is the working of SpecialCells(xlCellTypeBlanks) ?
- HansVogelaarAug 05, 2021MVP
It returns the range containing all blank cells in the range specified before SpecialCells, in this code the used range of the active sheet.
See Range.SpecialCells method (Excel) and XlCellType enumeration (Excel)
- ExcelAug 05, 2021Iron ContributorThank you so much sir😊