I want to write a macro that works as follows.
A user selects any number of cells and then uses a command button to execute a procedure.
How do i get the proceudure to execute only on the cells selected by the user.
Cheers
Printable View
I want to write a macro that works as follows.
A user selects any number of cells and then uses a command button to execute a procedure.
How do i get the proceudure to execute only on the cells selected by the user.
Cheers
You could use code simular to this:
Good luck!Code:Dim rng As Range
Dim iCount As Integer
Dim r As Integer, c As Integer
Set rng = Selection
For r = 1 To rng.Cells.Rows.Count
For c = 1 To rng.Cells.Columns.Count
iCount = iCount + 1
rng(r, c) = "Cell #" & iCount
Next
Next