Getting a Cell Value into a Macro!

N

N1KO

I have this macro

Sub Group()

Dim Cel As Integer

Range("B5").Select
For Cel = 1 To 115
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Rows.Group
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Next

Range("A1:C1").Select
ActiveSheet.Outline.ShowLevels RowLevels:=1

End Sub

What i need it to do is in the "For Cel = 1 To 115" line is to have the 115
as value from a cell if this is possible.

Example: For Cel = 1 To "E1's value" is this possible?

Do i need to Dim the value in the cell or anything?

Thanks in advance.
 
A

akphidelt

Dim Cel As Integer
Dim x as Integer
x = Range("E1").value
Range("B5").Select
For Cel = 1 To x

try this
 

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