Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dear experts,
How can i get user's input about range address in Macros? I know inputbox can do that like dim rng as range set rng =inputbox Prompt:="Getting Range Address", Title:="Test", Type:=8 But the interface is too simple, and it's not easy for common users who're not experienced at Excel as they might think they have to write the address and errors might happen. I hope I can use some tools like boxes when using functions in GUI interface, which are familiar to everyone. or you have better solutions. Many thanks in advance... |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The following is my code, and I want to replace this:
Set Labels(i) = Application.InputBox(prompt:="Select the Range Address for Series " & i, _ Title:="Selection", Type:=8) The Full code: Sub AddDataLables() Dim Labels() As Range Dim dialogrange As Range Dim LabelCell As Range Dim LabelValue As String Dim SeriesCounts As Integer Dim DataLabelCounts As Integer Dim i, j As Integer j = 1 If ActiveSheet.ChartObjects.Count = 0 Then MsgBox prompt:="No Charts Found in the sheet," _ & Chr(10) & "Please CHANGE sheets or" & Chr(10) & _ "Make a NEW chart", Buttons:=vbExclamation, Title:="Error Found" Exit Sub End If SeriesCounts = ActiveSheet.ChartObjects(1).Chart. _ SeriesCollection.Count ActiveSheet.ChartObjects(1).Chart.SeriesCollection (1).HasDataLabels = True DataLabelCounts = ActiveSheet.ChartObjects(1).Chart. _ SeriesCollection(1).DataLabels.Count ReDim Labels(1 To SeriesCounts) For i = 1 To SeriesCounts Set Labels(i) = Application.InputBox(prompt:="Select the Range Address for Series " & i, _ Title:="Selection", Type:=8) ActiveSheet.ChartObjects(1).Chart.SeriesCollection (i).HasDataLabels = True For Each LabelCell In Labels(i) ActiveSheet.ChartObjects(1).Chart. _ SeriesCollection(i).DataLabels(j - (i - 1) * DataLabelCounts).Text = LabelCell.Value j = j + 1 Next LabelCell Next i End Sub On 12ÔÂ1ÈÕ, ÏÂÎç6ʱ44·Ö, "Samuel Wu" wrote: Dear experts, How can i get user's input about range address in Macros? I know inputbox can do that like dim rng as range set rng =inputbox Prompt:="Getting Range Address", Title:="Test", Type:=8 But the interface is too simple, and it's not easy for common users who're not experienced at Excel as they might think they have to write the address and errors might happen. I hope I can use some tools like boxes when using functions in GUI interface, which are familiar to everyone. or you have better solutions. Many thanks in advance... |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Sumeif macro with range selection | Excel Discussion (Misc queries) | |||
Macro Range Selection | Excel Discussion (Misc queries) | |||
Macro to change list box input range based on selection made in another cell | Excel Programming | |||
Excel VBA - Range(Selection, Selection.End(xlDown)).Name issue. | Excel Programming | |||
Range selection code in a macro | Excel Programming |