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:eek:ffice:eek:ffice" /><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?
 

Some videos you may like

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
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
 

Kyle M

Board Regular
Joined
Apr 13, 2010
Messages
65
SOLVED: Add character to blank range

Thank you VoG this is exactly what I was trying to do!
 
Last edited:

Kyle M

Board Regular
Joined
Apr 13, 2010
Messages
65
SOLVED: Add character to blank range

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

Watch MrExcel Video

Forum statistics

Threads
1,127,798
Messages
5,626,941
Members
416,209
Latest member
tan21

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
Top