Aug 05 2021 04:37 AM - edited Aug 05 2021 05:01 AM
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 as dynamic as possible.
I tried this code, but not working -
Dim valueCells As Range
Dim valueRange As Range
set valueRange =
For Each valueCells In valueRange
If VBA.IsEmpty(valueCells.Value) = True Then
valueCells.Value = "Customer Unassigned"
End If
Next
Can you please help me out with the range here?
--Or--
What should i write in VBA code?
Please help..??
Here is a attached file..
Aug 05 2021 05:07 AM
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
Aug 05 2021 05:18 AM
Aug 05 2021 07:28 AM - edited Aug 05 2021 07:28 AM
SolutionIt 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)
Aug 05 2021 08:15 AM
Aug 05 2021 07:28 AM - edited Aug 05 2021 07:28 AM
SolutionIt 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)