Select & step

N

noyb

Like many I'm new to this so any help greatly appreciated.

What I want to do is have a user highlight a block (range) of cells then
run a macro which will step though each cell starting with the upper
left and working to the right row by row (like reading) with some code
performed at each cell.

Thanks
 
N

Nikos Yannacopoulos

The following piece of sample code goes through each cell in the
"highlighted" area and sets their values to increasing numbers:

Sub cell_by_cell()
i = 1
For Each cell In Selection
cell.Value = i
i = i + 1
Next
End Sub

You can change the code in the For ... Next loop to do what you want.

HTH,
Nikos
 
B

Bob Phillips

For Each cell In Selection
Debug.Print cell.Value
Next cell

is an example

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Top