![]() |
Getting a Cell Value into a Macro!
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. |
Getting a Cell Value into a Macro!
Dim Cel As Integer
Dim x as Integer x = Range("E1").value Range("B5").Select For Cel = 1 To x try this "N1KO" wrote: 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. |
Getting a Cell Value into a Macro!
Thanks fella,
I found a slightly easier way using "For Cel = 1 To Range("E1").Value" "akphidelt" wrote: Dim Cel As Integer Dim x as Integer x = Range("E1").value Range("B5").Select For Cel = 1 To x try this "N1KO" wrote: 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. |
All times are GMT +1. The time now is 12:32 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com