Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default How to get users' range selection in VBA macro?

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default How to get users' range selection in VBA macro?

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sumeif macro with range selection orquidea Excel Discussion (Misc queries) 14 August 29th 08 03:12 AM
Macro Range Selection Roy A.[_2_] Excel Discussion (Misc queries) 3 March 16th 08 04:38 PM
Macro to change list box input range based on selection made in another cell Sue[_6_] Excel Programming 3 October 7th 04 06:45 PM
Excel VBA - Range(Selection, Selection.End(xlDown)).Name issue. jonH Excel Programming 3 June 7th 04 09:13 PM
Range selection code in a macro Floss Excel Programming 1 December 30th 03 01:05 AM


All times are GMT +1. The time now is 11:08 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"