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

Hi All,

I have a worksheet with data in it. Based on the data also have a chart on
the same sheet plotted by rows. Using the macro below I am deleting rows
containing value color.

Dim r As Range
Dim lastRow As Long
Dim i As Long
Set r = ActiveSheet.UsedRange
lastRow = r.Rows(r.Rows.Count).Row
For i = lastRow To 3 Step -1
If InStr(1, Cells(i, 2), "Color", vbTextCompare) = 1 Then
Rows(i).Delete
End If
Next
ActiveSheet.UsedRange.Select
End Sub


Since I have the chart plotted by rows (Actually it should not matter wether
the chart is plotted by rows or by columns) I want to write a macro or
modify the macro I have above in a way that it assigns new range as a
source data for the chart.

Please help me

Yesh.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Update Macro

If you are deleting rows within the currently charted range, the chart
should adjust automatically.

--
Regards,
Tom Ogilvy


"Yeshwin" wrote in message
...
Hi All,

I have a worksheet with data in it. Based on the data also have a chart on
the same sheet plotted by rows. Using the macro below I am deleting rows
containing value color.

Dim r As Range
Dim lastRow As Long
Dim i As Long
Set r = ActiveSheet.UsedRange
lastRow = r.Rows(r.Rows.Count).Row
For i = lastRow To 3 Step -1
If InStr(1, Cells(i, 2), "Color", vbTextCompare) = 1 Then
Rows(i).Delete
End If
Next
ActiveSheet.UsedRange.Select
End Sub


Since I have the chart plotted by rows (Actually it should not matter

wether
the chart is plotted by rows or by columns) I want to write a macro or
modify the macro I have above in a way that it assigns new range as a
source data for the chart.

Please help me

Yesh.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Update Macro

Thanks for the reply, Tom. That's what I thought. But it adjusts only if the
chart is plotted by Columns but I am having trouble with charts plotted by
rows. There I get #ref for the rows missing

This is the reason I was wondering if you or anyone here could help me reset
or update the chart using macro so that we can assign the updated range.

Thanks

Yesh

"Tom Ogilvy" wrote in message
...
If you are deleting rows within the currently charted range, the chart
should adjust automatically.

--
Regards,
Tom Ogilvy


"Yeshwin" wrote in message
...
Hi All,

I have a worksheet with data in it. Based on the data also have a chart

on
the same sheet plotted by rows. Using the macro below I am deleting rows
containing value color.

Dim r As Range
Dim lastRow As Long
Dim i As Long
Set r = ActiveSheet.UsedRange
lastRow = r.Rows(r.Rows.Count).Row
For i = lastRow To 3 Step -1
If InStr(1, Cells(i, 2), "Color", vbTextCompare) = 1 Then
Rows(i).Delete
End If
Next
ActiveSheet.UsedRange.Select
End Sub


Since I have the chart plotted by rows (Actually it should not matter

wether
the chart is plotted by rows or by columns) I want to write a macro or
modify the macro I have above in a way that it assigns new range as a
source data for the chart.

Please help me

Yesh.






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Update Macro

If you destroy the entire source for the data, that would be correct.

I think you would just loop through the series and delete the series where
the formula has #Ref in it.

something like (after you delete the rows)

Dim ser as Series
for each ser in activechart.SeriesCollection
if instr(1,ser.Formula,"#REF",vbTextCompare) then
ser.Delete
end if
Next


Untested pseudo code, but I would think that would work.

--
Regards,
Tom Ogilvy



"Yeshwin" wrote in message
...
Thanks for the reply, Tom. That's what I thought. But it adjusts only if

the
chart is plotted by Columns but I am having trouble with charts plotted by
rows. There I get #ref for the rows missing

This is the reason I was wondering if you or anyone here could help me

reset
or update the chart using macro so that we can assign the updated range.

Thanks

Yesh

"Tom Ogilvy" wrote in message
...
If you are deleting rows within the currently charted range, the chart
should adjust automatically.

--
Regards,
Tom Ogilvy


"Yeshwin" wrote in message
...
Hi All,

I have a worksheet with data in it. Based on the data also have a

chart
on
the same sheet plotted by rows. Using the macro below I am deleting

rows
containing value color.

Dim r As Range
Dim lastRow As Long
Dim i As Long
Set r = ActiveSheet.UsedRange
lastRow = r.Rows(r.Rows.Count).Row
For i = lastRow To 3 Step -1
If InStr(1, Cells(i, 2), "Color", vbTextCompare) = 1 Then
Rows(i).Delete
End If
Next
ActiveSheet.UsedRange.Select
End Sub


Since I have the chart plotted by rows (Actually it should not matter

wether
the chart is plotted by rows or by columns) I want to write a macro or
modify the macro I have above in a way that it assigns new range as a
source data for the chart.

Please help me

Yesh.








  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Update Macro

Thanks a lot, Tom. Worked perfectly.

Yesh
"Yeshwin" wrote in message
...
Thanks for the reply, Tom. That's what I thought. But it adjusts only if

the
chart is plotted by Columns but I am having trouble with charts plotted by
rows. There I get #ref for the rows missing

This is the reason I was wondering if you or anyone here could help me

reset
or update the chart using macro so that we can assign the updated range.

Thanks

Yesh

"Tom Ogilvy" wrote in message
...
If you are deleting rows within the currently charted range, the chart
should adjust automatically.

--
Regards,
Tom Ogilvy


"Yeshwin" wrote in message
...
Hi All,

I have a worksheet with data in it. Based on the data also have a

chart
on
the same sheet plotted by rows. Using the macro below I am deleting

rows
containing value color.

Dim r As Range
Dim lastRow As Long
Dim i As Long
Set r = ActiveSheet.UsedRange
lastRow = r.Rows(r.Rows.Count).Row
For i = lastRow To 3 Step -1
If InStr(1, Cells(i, 2), "Color", vbTextCompare) = 1 Then
Rows(i).Delete
End If
Next
ActiveSheet.UsedRange.Select
End Sub


Since I have the chart plotted by rows (Actually it should not matter

wether
the chart is plotted by rows or by columns) I want to write a macro or
modify the macro I have above in a way that it assigns new range as a
source data for the chart.

Please help me

Yesh.








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
need help to update macro to office 2007 macro enabled workbook jatman Excel Discussion (Misc queries) 1 December 14th 07 01:57 PM
Macro need to update the workbook x6v87qe Excel Discussion (Misc queries) 6 May 3rd 07 04:42 AM
Macro update Roger[_20_] Excel Programming 4 July 13th 05 08:18 PM
dde link update in vba macro Knut Excel Programming 1 January 20th 04 12:55 AM
Macro update Rhonda[_2_] Excel Programming 1 September 12th 03 01:11 AM


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