Add character to blank range

Kyle M

Board Regular
Joined
Apr 13, 2010
Messages
65
Code:
[FONT=Times New Roman][SIZE=3]Sub DelRows()
Dim Variant As Range[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]Set Variant = Range("B172:B201")[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]On Error GoTo GetOut
Variant.SpecialCells(xlCellTypeBlanks).Select
On Error GoTo 0
If Selection.Count = <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /><st1:PlaceName w:st="on">Variant.Count</st1:PlaceName> <st1:PlaceName w:st="on">Then</st1:PlaceName> 'All cells were blank
<st1:PlaceType w:st="on">Range</st1:PlaceType>("171:209").EntireRow.Delete
Else
Selection.EntireRow.Delete
End If
GetOut:
'No blank cells[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]End Sub[/SIZE][/FONT]

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>
The macro I am using is above. Presently it checks range B172: B201 for data. If it finds data it does nothing. However if it does not find data it deletes the rows in range 171:209. Instead of deleting the rows in range 171:209, I would like to add asterisks to the rows in range B171:B209 but I am not sure how to change the code so that it can do that, would you be able to help me?
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Try

Code:
Sub AsterixRows()
Dim Var As Range
Set Var = Range("B172:B201")
On Error GoTo GetOut
Var.SpecialCells(xlCellTypeBlanks).Select
On Error GoTo 0
If Selection.Count = Var.Count Then 'All cells were blank
Range("171:209").Value = "*"
Else
Selection.Value = "*"
End If
GetOut:
'No blank cells
End Sub
 
Upvote 0
SOLVED: Add character to blank range

Thank you VoG this is exactly what I was trying to do!
 
Last edited:
Upvote 0
SOLVED: Add character to blank range

Andrew Poulsom, thank you for your help it is much appreciated!
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,723
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top