Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default Inputbox Question

I started with this code. It allows the user to input 4 lines of text into
a ChartTitle. I'm trying to modify it to allow the user to enter a single
line of text or up to 4 lines of text . I want it to exit the first time
the user doesn't input anything in the Inputboxes. Or be able to cancel the
inputbox without removing the text already in the chart title. I've tried
using a label and "If then GoTo" but not sure if this approach is right or
how to get it to work. I can post the revised code if it might be helpful.

Joel Mills

Sub ChartTitle()

Dim CTitle1 As String
Dim CTitle2 As String
Dim CTitle3 As String
Dim CTitle4 As String
ChartTitle1 = InputBox("Enter 1st Line of Chart Title")
ChartTitle2 = InputBox("Enter 2nd Line of Chart Title")
ChartTitle3 = InputBox("Enter 3rd Line of Chart Title")
ChartTitle4 = InputBox("Enter 4th Line of Chart Title")

ActiveSheet.ChartObjects("Curve Chart").Activate
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = ChartTitle1 & Chr(10) _
& ChartTitle2 & Chr(10) & ChartTitle3 & Chr(10) _
& ChartTitle4 & Chr(10)
End With

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Inputbox Question

Hi,

Try this:


Option Explicit


Sub ChartTitle()

Dim ChartTitles As String, TitleStr As String, i As Integer

ChartTitles = ""
For i = 1 To 4
TitleStr = InputBox("Enter line " & i & " of chart title")
If TitleStr < "" Then
ChartTitles = ChartTitles + TitleStr + Chr(10)
Else
Exit For
End If
Next i


MsgBox ChartTitle
ActiveSheet.ChartObjects("Curve Chart").Activate
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = ChartTitles
End With

End Sub


HTH

"Joel Mills" wrote:

I started with this code. It allows the user to input 4 lines of text into
a ChartTitle. I'm trying to modify it to allow the user to enter a single
line of text or up to 4 lines of text . I want it to exit the first time
the user doesn't input anything in the Inputboxes. Or be able to cancel the
inputbox without removing the text already in the chart title. I've tried
using a label and "If then GoTo" but not sure if this approach is right or
how to get it to work. I can post the revised code if it might be helpful.

Joel Mills

Sub ChartTitle()

Dim CTitle1 As String
Dim CTitle2 As String
Dim CTitle3 As String
Dim CTitle4 As String
ChartTitle1 = InputBox("Enter 1st Line of Chart Title")
ChartTitle2 = InputBox("Enter 2nd Line of Chart Title")
ChartTitle3 = InputBox("Enter 3rd Line of Chart Title")
ChartTitle4 = InputBox("Enter 4th Line of Chart Title")

ActiveSheet.ChartObjects("Curve Chart").Activate
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = ChartTitle1 & Chr(10) _
& ChartTitle2 & Chr(10) & ChartTitle3 & Chr(10) _
& ChartTitle4 & Chr(10)
End With

End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default Inputbox Question

Toppers,

Thanks for your help. This does exactly what I wanted. Only had to fix a
typo in your code. MsgBox ChartTitle to MsgBox ChartTitles.
Again thanks. Wow that was a fast reply.

"Toppers" wrote in message
...
Hi,

Try this:


Option Explicit


Sub ChartTitle()

Dim ChartTitles As String, TitleStr As String, i As Integer

ChartTitles = ""
For i = 1 To 4
TitleStr = InputBox("Enter line " & i & " of chart title")
If TitleStr < "" Then
ChartTitles = ChartTitles + TitleStr + Chr(10)
Else
Exit For
End If
Next i


MsgBox ChartTitle
ActiveSheet.ChartObjects("Curve Chart").Activate
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = ChartTitles
End With

End Sub


HTH

"Joel Mills" wrote:

I started with this code. It allows the user to input 4 lines of text
into
a ChartTitle. I'm trying to modify it to allow the user to enter a
single
line of text or up to 4 lines of text . I want it to exit the first time
the user doesn't input anything in the Inputboxes. Or be able to cancel
the
inputbox without removing the text already in the chart title. I've
tried
using a label and "If then GoTo" but not sure if this approach is right
or
how to get it to work. I can post the revised code if it might be
helpful.

Joel Mills

Sub ChartTitle()

Dim CTitle1 As String
Dim CTitle2 As String
Dim CTitle3 As String
Dim CTitle4 As String
ChartTitle1 = InputBox("Enter 1st Line of Chart Title")
ChartTitle2 = InputBox("Enter 2nd Line of Chart Title")
ChartTitle3 = InputBox("Enter 3rd Line of Chart Title")
ChartTitle4 = InputBox("Enter 4th Line of Chart Title")

ActiveSheet.ChartObjects("Curve Chart").Activate
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = ChartTitle1 & Chr(10) _
& ChartTitle2 & Chr(10) & ChartTitle3 & Chr(10) _
& ChartTitle4 & Chr(10)
End With

End Sub





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Inputbox Question

Hi,
I spotted my typo after posting - just testing you! Glad it helped.

"Joel Mills" wrote:

Toppers,

Thanks for your help. This does exactly what I wanted. Only had to fix a
typo in your code. MsgBox ChartTitle to MsgBox ChartTitles.
Again thanks. Wow that was a fast reply.

"Toppers" wrote in message
...
Hi,

Try this:


Option Explicit


Sub ChartTitle()

Dim ChartTitles As String, TitleStr As String, i As Integer

ChartTitles = ""
For i = 1 To 4
TitleStr = InputBox("Enter line " & i & " of chart title")
If TitleStr < "" Then
ChartTitles = ChartTitles + TitleStr + Chr(10)
Else
Exit For
End If
Next i


MsgBox ChartTitle
ActiveSheet.ChartObjects("Curve Chart").Activate
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = ChartTitles
End With

End Sub


HTH

"Joel Mills" wrote:

I started with this code. It allows the user to input 4 lines of text
into
a ChartTitle. I'm trying to modify it to allow the user to enter a
single
line of text or up to 4 lines of text . I want it to exit the first time
the user doesn't input anything in the Inputboxes. Or be able to cancel
the
inputbox without removing the text already in the chart title. I've
tried
using a label and "If then GoTo" but not sure if this approach is right
or
how to get it to work. I can post the revised code if it might be
helpful.

Joel Mills

Sub ChartTitle()

Dim CTitle1 As String
Dim CTitle2 As String
Dim CTitle3 As String
Dim CTitle4 As String
ChartTitle1 = InputBox("Enter 1st Line of Chart Title")
ChartTitle2 = InputBox("Enter 2nd Line of Chart Title")
ChartTitle3 = InputBox("Enter 3rd Line of Chart Title")
ChartTitle4 = InputBox("Enter 4th Line of Chart Title")

ActiveSheet.ChartObjects("Curve Chart").Activate
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = ChartTitle1 & Chr(10) _
& ChartTitle2 & Chr(10) & ChartTitle3 & Chr(10) _
& ChartTitle4 & Chr(10)
End With

End Sub






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default Inputbox Question

Oops, I spoke to soon. I'm positive my users will run this macro and then
decide to close it without inputting anything. If they do this it will
clear out the ChartTitle. Is there a way to have cancel close the InputBox
without clearing the Chart Title?


"Toppers" wrote in message
...
Hi,

Try this:


Option Explicit


Sub ChartTitle()

Dim ChartTitles As String, TitleStr As String, i As Integer

ChartTitles = ""
For i = 1 To 4
TitleStr = InputBox("Enter line " & i & " of chart title")
If TitleStr < "" Then
ChartTitles = ChartTitles + TitleStr + Chr(10)
Else
Exit For
End If
Next i


MsgBox ChartTitle
ActiveSheet.ChartObjects("Curve Chart").Activate
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = ChartTitles
End With

End Sub


HTH

"Joel Mills" wrote:

I started with this code. It allows the user to input 4 lines of text
into
a ChartTitle. I'm trying to modify it to allow the user to enter a
single
line of text or up to 4 lines of text . I want it to exit the first time
the user doesn't input anything in the Inputboxes. Or be able to cancel
the
inputbox without removing the text already in the chart title. I've
tried
using a label and "If then GoTo" but not sure if this approach is right
or
how to get it to work. I can post the revised code if it might be
helpful.

Joel Mills

Sub ChartTitle()

Dim CTitle1 As String
Dim CTitle2 As String
Dim CTitle3 As String
Dim CTitle4 As String
ChartTitle1 = InputBox("Enter 1st Line of Chart Title")
ChartTitle2 = InputBox("Enter 2nd Line of Chart Title")
ChartTitle3 = InputBox("Enter 3rd Line of Chart Title")
ChartTitle4 = InputBox("Enter 4th Line of Chart Title")

ActiveSheet.ChartObjects("Curve Chart").Activate
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = ChartTitle1 & Chr(10) _
& ChartTitle2 & Chr(10) & ChartTitle3 & Chr(10) _
& ChartTitle4 & Chr(10)
End With

End Sub







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Inputbox Question

Hi again,

Try:


ActiveSheet.ChartObjects("Curve Chart").Activate
With ActiveChart
.HasTitle = True
If ChartTitles < "" then ' Replace only if there is an entry in
ChartTitles
.ChartTitle.Characters.Text = ChartTitles
End If
End With

HTH

"Joel Mills" wrote:

Oops, I spoke to soon. I'm positive my users will run this macro and then
decide to close it without inputting anything. If they do this it will
clear out the ChartTitle. Is there a way to have cancel close the InputBox
without clearing the Chart Title?


"Toppers" wrote in message
...
Hi,

Try this:


Option Explicit


Sub ChartTitle()

Dim ChartTitles As String, TitleStr As String, i As Integer

ChartTitles = ""
For i = 1 To 4
TitleStr = InputBox("Enter line " & i & " of chart title")
If TitleStr < "" Then
ChartTitles = ChartTitles + TitleStr + Chr(10)
Else
Exit For
End If
Next i


MsgBox ChartTitle
ActiveSheet.ChartObjects("Curve Chart").Activate
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = ChartTitles
End With

End Sub


HTH

"Joel Mills" wrote:

I started with this code. It allows the user to input 4 lines of text
into
a ChartTitle. I'm trying to modify it to allow the user to enter a
single
line of text or up to 4 lines of text . I want it to exit the first time
the user doesn't input anything in the Inputboxes. Or be able to cancel
the
inputbox without removing the text already in the chart title. I've
tried
using a label and "If then GoTo" but not sure if this approach is right
or
how to get it to work. I can post the revised code if it might be
helpful.

Joel Mills

Sub ChartTitle()

Dim CTitle1 As String
Dim CTitle2 As String
Dim CTitle3 As String
Dim CTitle4 As String
ChartTitle1 = InputBox("Enter 1st Line of Chart Title")
ChartTitle2 = InputBox("Enter 2nd Line of Chart Title")
ChartTitle3 = InputBox("Enter 3rd Line of Chart Title")
ChartTitle4 = InputBox("Enter 4th Line of Chart Title")

ActiveSheet.ChartObjects("Curve Chart").Activate
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = ChartTitle1 & Chr(10) _
& ChartTitle2 & Chr(10) & ChartTitle3 & Chr(10) _
& ChartTitle4 & Chr(10)
End With

End Sub






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default Inputbox Question

Hi Toppers,

Thanks for your help. I've been trying to figure this out since your first
post. Pulling out what little hair I have. I was trying write the code
based on TitleStr instead of the ChartTitle being empty or not.

"Toppers" wrote in message
...
Hi again,

Try:


ActiveSheet.ChartObjects("Curve Chart").Activate
With ActiveChart
.HasTitle = True
If ChartTitles < "" then ' Replace only if there is an entry in
ChartTitles
.ChartTitle.Characters.Text = ChartTitles
End If
End With

HTH

"Joel Mills" wrote:

Oops, I spoke to soon. I'm positive my users will run this macro and then
decide to close it without inputting anything. If they do this it will
clear out the ChartTitle. Is there a way to have cancel close the
InputBox
without clearing the Chart Title?


"Toppers" wrote in message
...
Hi,

Try this:


Option Explicit


Sub ChartTitle()

Dim ChartTitles As String, TitleStr As String, i As Integer

ChartTitles = ""
For i = 1 To 4
TitleStr = InputBox("Enter line " & i & " of chart title")
If TitleStr < "" Then
ChartTitles = ChartTitles + TitleStr + Chr(10)
Else
Exit For
End If
Next i


MsgBox ChartTitle
ActiveSheet.ChartObjects("Curve Chart").Activate
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = ChartTitles
End With

End Sub


HTH

"Joel Mills" wrote:

I started with this code. It allows the user to input 4 lines of text
into
a ChartTitle. I'm trying to modify it to allow the user to enter a
single
line of text or up to 4 lines of text . I want it to exit the first
time
the user doesn't input anything in the Inputboxes. Or be able to
cancel
the
inputbox without removing the text already in the chart title. I've
tried
using a label and "If then GoTo" but not sure if this approach is
right
or
how to get it to work. I can post the revised code if it might be
helpful.

Joel Mills

Sub ChartTitle()

Dim CTitle1 As String
Dim CTitle2 As String
Dim CTitle3 As String
Dim CTitle4 As String
ChartTitle1 = InputBox("Enter 1st Line of Chart Title")
ChartTitle2 = InputBox("Enter 2nd Line of Chart Title")
ChartTitle3 = InputBox("Enter 3rd Line of Chart Title")
ChartTitle4 = InputBox("Enter 4th Line of Chart Title")

ActiveSheet.ChartObjects("Curve Chart").Activate
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = ChartTitle1 & Chr(10) _
& ChartTitle2 & Chr(10) & ChartTitle3 & Chr(10) _
& ChartTitle4 & Chr(10)
End With

End Sub








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
Another InputBox question... Phil Excel Discussion (Misc queries) 4 April 12th 07 03:37 PM
inputbox question redb Excel Discussion (Misc queries) 0 October 6th 05 02:57 PM
VBA question involving an InputBox Don Lindros Excel Programming 1 April 13th 04 01:04 PM
VBA question involving an InputBox Don Lindros Excel Programming 3 April 12th 04 04:57 PM
Inputbox question Nancy[_4_] Excel Programming 3 December 12th 03 01:56 AM


All times are GMT +1. The time now is 08:00 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"