Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default [VBA] Convert string to Range

Hi,
I would like to know how I can convert a string in a range.

I write what I did:
I have one sheet with inside four charts (grafichs).
In this charts I have only to insert the source data.

<----------------------------------------------------------------------
Private Sub Crea_grafico(foglio As String, tabella As String,
nome_tabella As String, foglio2 As String, marca As String)
Dim WB As Workbook
Dim SH As Worksheet
Dim area_grafico As Range
Dim area As String

Set WB = Workbooks(nuova_cartella)
Set SH = WB.Sheets(foglio)

' Here I determine the variable area
' area as this kind of value "I15,K15,P15,Z15,I39,K39,P39,Z39"
<------- I checked it with debug and it's ok

Set area_grafico = SH.Range(area)
' Here the macro stops with a '1004 Error'
' The strange behavoiur is that after it stops, I press F8 and the
instruction is ok and the macro goes on very well.

Sheets(foglio_grafici).ChartObjects("Grafico 2").Activate
ActiveChart.ChartArea.Select
ActiveChart.SetSourceData Source:=SH.Range(area), PlotBy:=xlRows
<----------------------------------------------------------------------

I use Excel 2003 SP2 (Italian version)
Who can help me??

Thanks in advance!!!!

--
Ciao Denis

Arriva un momento nella vita in cui non rimane altro da fare che
percorrere la propria strada fino in fondo...
Quello e' il momento di inseguire i propri sogni, quello e' il momento
di prendere il largo, forti delle proprie convinzioni.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default [VBA] Convert string to Range

Without testing...

The worksheet that owns the thing that should be activated has to be active.
Maybe it's as simple as making sure you're on the correct worksheet first.

application.goto Sheets(foglio_grafici).range("a1")
Sheets(foglio_grafici).ChartObjects("Grafico 2").Activate

===
You could also select the workbook, then select the sheet, too:

with sheets(foglio_grafici)
.parent.activate
.select
.chartobjects("grafico 2").activate
end with



Denis wrote:

Hi,
I would like to know how I can convert a string in a range.

I write what I did:
I have one sheet with inside four charts (grafichs).
In this charts I have only to insert the source data.

<----------------------------------------------------------------------
Private Sub Crea_grafico(foglio As String, tabella As String,
nome_tabella As String, foglio2 As String, marca As String)
Dim WB As Workbook
Dim SH As Worksheet
Dim area_grafico As Range
Dim area As String

Set WB = Workbooks(nuova_cartella)
Set SH = WB.Sheets(foglio)

' Here I determine the variable area
' area as this kind of value "I15,K15,P15,Z15,I39,K39,P39,Z39"
<------- I checked it with debug and it's ok

Set area_grafico = SH.Range(area)
' Here the macro stops with a '1004 Error'
' The strange behavoiur is that after it stops, I press F8 and the
instruction is ok and the macro goes on very well.

Sheets(foglio_grafici).ChartObjects("Grafico 2").Activate
ActiveChart.ChartArea.Select
ActiveChart.SetSourceData Source:=SH.Range(area), PlotBy:=xlRows
<----------------------------------------------------------------------

I use Excel 2003 SP2 (Italian version)
Who can help me??

Thanks in advance!!!!

--
Ciao Denis

Arriva un momento nella vita in cui non rimane altro da fare che
percorrere la propria strada fino in fondo...
Quello e' il momento di inseguire i propri sogni, quello e' il momento
di prendere il largo, forti delle proprie convinzioni.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default [VBA] Convert string to Range

Dave Peterson ha scritto:
The worksheet that owns the thing that should be activated has to be active.
Maybe it's as simple as making sure you're on the correct worksheet first.


Yes I'm on the correct worksheet.

application.goto Sheets(foglio_grafici).range("a1")


Why this??

Sheets(foglio_grafici).ChartObjects("Grafico 2").Activate


I do this.

with sheets(foglio_grafici)
.parent.activate
.select
.chartobjects("grafico 2").activate
end with


The error is always on SetSourceData

--
Ciao Denis

Arriva un momento nella vita in cui non rimane altro da fare che
percorrere la propria strada fino in fondo...
Quello e' il momento di inseguire i propri sogni, quello e' il momento
di prendere il largo, forti delle proprie convinzioni.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default [VBA] Convert string to Range

I couldn't tell which line had the problem.

In a different forum for a different problem (working with pivottables), someone
said that adding this line right before the offending line helped them.

Application.Wait Now + TimeSearial(0,0,1)

It's just a way to pause for a second.

I don't know if it'll help you, though.

Denis wrote:

Dave Peterson ha scritto:
The worksheet that owns the thing that should be activated has to be active.
Maybe it's as simple as making sure you're on the correct worksheet first.


Yes I'm on the correct worksheet.

application.goto Sheets(foglio_grafici).range("a1")


Why this??

Sheets(foglio_grafici).ChartObjects("Grafico 2").Activate


I do this.

with sheets(foglio_grafici)
.parent.activate
.select
.chartobjects("grafico 2").activate
end with


The error is always on SetSourceData

--
Ciao Denis

Arriva un momento nella vita in cui non rimane altro da fare che
percorrere la propria strada fino in fondo...
Quello e' il momento di inseguire i propri sogni, quello e' il momento
di prendere il largo, forti delle proprie convinzioni.


--

Dave Peterson
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
convert a string to range? JK Excel Worksheet Functions 4 June 20th 06 01:04 AM
Convert string to range? k Excel Programming 4 April 9th 04 09:03 PM
Convert String of 512 numbers to a range Kevin G[_2_] Excel Programming 10 February 2nd 04 06:02 AM
Scenariao needing help with. convert range to string and back, Kevin G[_2_] Excel Programming 0 January 28th 04 03:23 PM
VBA - Convert my variable range array to single cell string Kevin G[_2_] Excel Programming 6 January 28th 04 07:20 AM


All times are GMT +1. The time now is 11:24 PM.

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

About Us

"It's about Microsoft Excel"