Question : VBA Excel loop through selected area

I'm a novice to VBA and am trying to loop through a selected area prompting for a value for each cell.  I'm getting an error.  Attached is the code. Can someone tell me what I'm doing wrong?  
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
Sub LoopThrough()
Dim c As Range
Dim cellValue As Variant
Dim SelectedCells As Range
Set SelectedCells = Selection
For Each c In Range(SelectedCells)

    cellValue = InputBox("Gimme a value")
    c.Value = cellValue

Next c

End Sub

Answer : VBA Excel loop through selected area

Sub LoopThrough()
Dim c As Range
Dim cellValue As Variant

For Each c In Selection

    cellValue = InputBox("Gimme a value")
    c.Value = cellValue

Next c

End Sub

Random Solutions  
 
programming4us programming4us