Fill series in visible cells only

R

RossM

Can any one suggest a way to fill only the visible cells in a filtere
range with a numerical series. I'm dealing with a data base for tissu
culture where after filtering the rows the filtered group are assigne
new experimental numbers the simplest being 1 - 96 but this serie
needs to skip all the filtered rows.

I think I need a VBA macro but don't know the programming language.
guess a macro needs to loop through the cells assesing their propert
for visibility or not and incrementing their value as appropriate

Thanks Ros
 
K

Ken Wright

Select the range and run this:-

Sub DataSeries()

Dim Start As Long
Dim Incr As Long
Dim cel As Range
Dim rng As Range

Set rng = selection.SpecialCells(xlCellTypeVisible)

Start = InputBox("What is the start value of your number series")
Incr = InputBox("What is the incremental value you wish to use")

For Each cel In rng
cel.Value = Start
Start = Start + Incr
Next cel

End Sub
 
R

RossM

Thanks for the macro it works very well - very elegant

One question

Why does the macro know that cel is the first cell in rng and only on
cell this doesn't seem to be defined anywhere in the code?
Regards
Ros
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top