Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Determine if a chart exists
All,
I've been using the search feature, but haven't crossed over a situation where someone needed to determine if a chart exists. I am giving the user the ability to run a snippet of code over again if they change something. It essentially will regraph everything. I want to first delete the Chart it had previously made if there were one and then recreate it. Here is my code below. I have an error message with the first line. The two arr* terms are arrays that have a defined name. Set shtnme = Worksheets(arrFileList(FileNum) & "_" & arrLayers(LayerNum)) 'Delete graph if already there cause user reran graphing tool If Not shtnme Is Nothing Then Sheets(shtnme).Delete Else: End If |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Determine if a chart exists
ChartName = arrFileList(FileNum) & "_" & arrLayers(LayerNum) Found = false for each sht in worksheets if sht.name = ChartName then Found = true exit for end if next sht if found = true then Sheets(ChartName).Delete end if "Matt S" wrote: All, I've been using the search feature, but haven't crossed over a situation where someone needed to determine if a chart exists. I am giving the user the ability to run a snippet of code over again if they change something. It essentially will regraph everything. I want to first delete the Chart it had previously made if there were one and then recreate it. Here is my code below. I have an error message with the first line. The two arr* terms are arrays that have a defined name. Set shtnme = Worksheets(arrFileList(FileNum) & "_" & arrLayers(LayerNum)) 'Delete graph if already there cause user reran graphing tool If Not shtnme Is Nothing Then Sheets(shtnme).Delete Else: End If |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Determine if a chart exists
Thank you Joel!!
<3 Matt "joel" wrote: ChartName = arrFileList(FileNum) & "_" & arrLayers(LayerNum) Found = false for each sht in worksheets if sht.name = ChartName then Found = true exit for end if next sht if found = true then Sheets(ChartName).Delete end if "Matt S" wrote: All, I've been using the search feature, but haven't crossed over a situation where someone needed to determine if a chart exists. I am giving the user the ability to run a snippet of code over again if they change something. It essentially will regraph everything. I want to first delete the Chart it had previously made if there were one and then recreate it. Here is my code below. I have an error message with the first line. The two arr* terms are arrays that have a defined name. Set shtnme = Worksheets(arrFileList(FileNum) & "_" & arrLayers(LayerNum)) 'Delete graph if already there cause user reran graphing tool If Not shtnme Is Nothing Then Sheets(shtnme).Delete Else: End If |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Determine if a chart exists
Joel,
that went over the sheets in my workbook, but not the charts. Will replacing "for each sht in worksheets" with "for each cht in charts" work? Thanks, Matt "joel" wrote: ChartName = arrFileList(FileNum) & "_" & arrLayers(LayerNum) Found = false for each sht in worksheets if sht.name = ChartName then Found = true exit for end if next sht if found = true then Sheets(ChartName).Delete end if "Matt S" wrote: All, I've been using the search feature, but haven't crossed over a situation where someone needed to determine if a chart exists. I am giving the user the ability to run a snippet of code over again if they change something. It essentially will regraph everything. I want to first delete the Chart it had previously made if there were one and then recreate it. Here is my code below. I have an error message with the first line. The two arr* terms are arrays that have a defined name. Set shtnme = Worksheets(arrFileList(FileNum) & "_" & arrLayers(LayerNum)) 'Delete graph if already there cause user reran graphing tool If Not shtnme Is Nothing Then Sheets(shtnme).Delete Else: End If |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Determine if a chart exists
Yeah, didn't you try it?
- Jon ------- Jon Peltier, Peltier Technical Services, Inc. http://PeltierTech.com/WordPress/ Advanced Excel Conference - June 17-18 2009 - Charting and Programming http://peltiertech.com/Training/2009...00906ACNJ.html _______ "Matt S" wrote in message ... Joel, that went over the sheets in my workbook, but not the charts. Will replacing "for each sht in worksheets" with "for each cht in charts" work? Thanks, Matt "joel" wrote: ChartName = arrFileList(FileNum) & "_" & arrLayers(LayerNum) Found = false for each sht in worksheets if sht.name = ChartName then Found = true exit for end if next sht if found = true then Sheets(ChartName).Delete end if "Matt S" wrote: All, I've been using the search feature, but haven't crossed over a situation where someone needed to determine if a chart exists. I am giving the user the ability to run a snippet of code over again if they change something. It essentially will regraph everything. I want to first delete the Chart it had previously made if there were one and then recreate it. Here is my code below. I have an error message with the first line. The two arr* terms are arrays that have a defined name. Set shtnme = Worksheets(arrFileList(FileNum) & "_" & arrLayers(LayerNum)) 'Delete graph if already there cause user reran graphing tool If Not shtnme Is Nothing Then Sheets(shtnme).Delete Else: End If |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Determine if Sub Exists | Excel Programming | |||
VBA:: determine if UDF exists? | Excel Discussion (Misc queries) | |||
Determine if a File Exists | Excel Discussion (Misc queries) | |||
Determine if a File Exists | Excel Programming | |||
determine if value exists | Excel Programming |