Re: How to make space between bars in a graph?
- From: BeWyched <BeWyched@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 15 Dec 2006 02:52:01 -0800
Hi Amit
I'm pleased to coding worked.
To get rid of the characters I'd use a simple loop and chop them out one by
one.
e.g.
Private Function StringFilter(Strng As String)
Dim FilteredStrng As String, n As Integer
FilteredStrng = ""
For n = 1 To Len(Strng)
If Mid(Strng, n, 1) = "*" Or Mid(Strng, n, 1) = "?" Or Mid(Strng, n, 1)
= "/" Then
GoTo Continue
Else
FilteredStrng = FilteredStrng & Mid(Strng, n, 1)
End If
Continue:
Next n
StringFilter = FilteredStrng
End Function
I've used 3 characters to get rid of - *, / and ?. You can change this line
to suit. Add the module to your form's module and call it using:
StringFilter("String returned from your server goes here")
Good luck.
BW
"Amit" wrote:
.
Hi BeWyched,
Thanks! yes it works now I tried the loop you had pointed. As I said
works just fine only it flickers when goes thru the loop to change
color of each bar.
One more thing I need to ask is that how can I process a text? for
instance I send a request to a server and it sends me back some
strings. These strings are like:
App Key (*)
Search eng (*/*)(*/*)
and so on ...
I need to filter out those wild cards. What functionality of VBA can
hlep me to wipe them out?
Thanks again for your concern and helping me out with my question.
Thanks,
AK
BeWyched wrote:
Hi
It should work? Does the code compile?
It could be that its not recognising the series index (1). To make sure it
picks up all the series try:
For n = 1 to TheChart.SeriesCollection.Count
TheChart.SeriesCollection(n).Interior.Color =RGB(0, 123, 0)
Next n
If this doesn't work you could try the alternative:
TheChart.SeriesCollection(1).Interior.ColorIndex = 3
This '3' sets the colour to Red etc. (I've never used this but know that 3 =
Red and 5 = Blue - not sure what the other colours are!)
Good luck.
BW
"Amit" wrote:
Hi BeWyched ,
Thank you so much for your response. The gapwidth works nicely but the
interior.color property doesn't cause any effect. Am I missing
something here?
However, as one of you had asked for the source code I have posted here
as following:
Dim TheChart As Chart
Dim Data*** As Work***
Dim CatTitles As Range
Dim SrcRange As Range
Dim SourceData As Range
Set TheChart = Sheets("Chart1")
Set DataSheet = Sheets("Sheet1")
With Data***
Set CatTitles = .Range("B7:B7")
Set SrcRange = .Range(Cells(8, Item), _
.Cells(38, Item))
End With
Set SourceData = Union(CatTitles, SrcRange)
TheChart.ChartArea.Width = 2
With TheChart
.SetSourceData Source:=SourceData, PlotBy:=xlColumn
.ChartTitle.Left = TheChart.ChartArea.Left
.ApplyDataLabels xlDataLabelsShowValue
.ChartGroups(1).Overlap = -50
.ChartGroups(1).GapWidth = 150
.Deselect
End With
BeWyched wrote:
Hi
I'm assuming you know how to create a chart/graph object using VBA. Assuming
the object is, say, objGraph then:
1. objGraph.SeriesCollection(1).Interior.Color = RGB(0, 128, 0)
will change the bar colour - change (1) to whatever the series is you want
to amend if you have more than 1 series. You will need change the RGB
settings to get the colour you need (steal the settings from Windows colour
pallet). Note that you can also set the Border colour using the same coding -
just change 'Interior' to 'Border'
2. objGraph .ChartGroups(1).Overlap = 50
and objGraph.ChartGroups(1).GapWidth = 150
will change the overlap (if there is more than 1 series) and the width
between groups of bars. Change the 50/100 to whatever suits - by default
Overlap will be 0 (i.e. no overlap), and Gapwidth 150'ish for most graphs.
3. Don't know!
Good luck
BW
"Amit" wrote:
Hello Group,
1) does anybody know how to create gaps between bars in graph using VBA
coding?
2) also, how can I make them have same color rahter different colors ?
3 ) How to make it ready only in a way that doesn't let use copy or
paste thing at all? this applies to chart and also to *** page.
Thanks,
AK
- Follow-Ups:
- References:
- How to make space between bars in a graph?
- From: Amit
- Re: How to make space between bars in a graph?
- From: Amit
- Re: How to make space between bars in a graph?
- From: BeWyched
- Re: How to make space between bars in a graph?
- From: Amit
- How to make space between bars in a graph?
- Prev by Date: Re: VBProperCase for Memo Controls?
- Next by Date: RE: fill in table
- Previous by thread: Re: How to make space between bars in a graph?
- Next by thread: Re: How to make space between bars in a graph?
- Index(es):