Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with adding in macro

Status
Not open for further replies.

tonyvee1973

IS-IT--Management
Oct 22, 2009
156
GB
Hi All

Have a spreadsheet with empty cells in which i need to fill with specified values.
I have used the formula below to add zero's to empty cells in the specified range.

Sub Fill_Blanks()
Dim MyCell As Range
For Each MyCell In Range(Selection.Address)
If MyCell = vbNullString Then
MyCell.Value = 0
End If
Next
End Sub

This works great but now i have another issue.
In one column i have a list of codes duplicated several times and now i need to add another 6 codes to the list.

Is there any way i can adapt the formula above to allow me to specify the 6 codes i need to add and get them in the empty spaces i have created for them?

I have tried variations of below but this doesnt work.

Sub Fill_Blanks()
Dim MyCell As Range
For Each MyCell In Range(Selection.Address)
If MyCell = vbNullString Then
MyCell.Value = 55400, 55401, 55402, 55403, 55404, 55405
End If
Next
End Sub

Any hekp really would be appreciated

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top