Getting at the range or cells

A

Andreww

Hi - I have been given the code below and have not used VB functions
much before.

What it does is alows a user to select a cell in a grid of numbers, a
range "selectedrow" is then created which provides the source data for
a graph.

My problem is that the grid has certain columns hidden by default and
thus the graph only uses as its source data from the non-hidden cols.

Does anyone know how I could get some value from the function which
would allow me to somehow manipulate the values the function returns
to enable my graph to see all the cols?

Thanks

Andrew

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Dim valrange As Integer
Dim end_row1 As Integer
Dim rowcheck As Integer


If Target.Row >= 8 And Target.Row <= 8 +
ActiveWorkbook.Names("numValues").RefersToRange.Value - 1 _
And Target.Column >= 3 And Target.Column <= 16 Then

ActiveWorkbook.Names("Data").RefersToRange.Interior.ColorIndex
= 0
ActiveWorkbook.Names("Data").RefersToRange.Font.Color = 1

'Range("B10:B" & end_val + 9).Name = "Left_chart_labels"


ThisWorkbook.Names("ValRange").RefersToRange.Interior.ColorIndex = 0
ThisWorkbook.Names("ValRange").RefersToRange.Font.ColorIndex =
1


ThisWorkbook.Names("SelectedRow").RefersToRange.Interior.ColorIndex =
4

ThisWorkbook.Names("SelectedCol").RefersToRange.Font.ColorIndex = 5

ActiveWorkbook.Names("highlightCol").RefersToRange.Value =
Target.Column - 3
ActiveWorkbook.Names("highlightRow").RefersToRange.Value =
Target.Row - 10


ThisWorkbook.Names("SelectedRow").RefersToRange.Interior.ColorIndex =
25

ThisWorkbook.Names("SelectedRow").RefersToRange.Font.ColorIndex = 19


ThisWorkbook.Names("SelectedCol").RefersToRange.Interior.ColorIndex =
25

ThisWorkbook.Names("SelectedCol").RefersToRange.Font.ColorIndex = 19

Target.Interior.ColorIndex = 0
Target.Font.ColorIndex = 1

End If

End Sub
 
G

Guest

with you chart selected, go to Tools=>Options, then go to the Chart tab.
Uncheck Chart Visible Cells Only.
 
A

Andreww

Actually have found following solution...

put this code at the top of the function

If Not Intersect(Target, Range("Data")) Is Nothing Then
Range("A2").Value = Target.Row
End If

And it puts selected row number in cell A2 on the worksheet. As I
know all the columns I can create a data source for the chart outside
of the grid.

Thanks Tom anyway... hope this helps someone else.

Regards

Andrew
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top