I've tried the F9 and switching to other sheets, but the graphs do not
re-appear.
I have 3 "printed" pages of graphs. W/ my zoom set at 50% I can see a
portion of the first page on my monitor. After running the script a few
times, w/out doing any scrolling, the graphs that did not have any portion
showing on my monitor appear to have been deleted, or "sent to back" against
the sheet. There is no sign of them.
I have even tried toggling between Page Break Preview and Normal views to
get them to refresh. No luck.
Here's the code:
Sub UpdateGraphRows()
'
' UpdateGraphRows Macro
'
' Keyboard Shortcut: Ctrl+Shift+R
'
Dim oChart As ChartObject
Dim mySrs As Series
Dim NewRow As String
Dim OldFormula As String
Dim FormulaParts() As String
Dim OldRow As String
Dim oSheet As Worksheet
Dim ReplaceValueFound As Boolean
Dim OriginalZoom As Variant
Dim FORCED_ZOOM As Variant
FORCED_ZOOM = 10
'Application.ScreenUpdating = False
NewRow = InputBox("Please enter new ""final"" row number", "New Row
Number")
If NewRow = "" Then
MsgBox "You must enter a new end row.", vbOKOnly, "No Row Provided"
Exit Sub
Else
For Each oSheet In ActiveWorkbook.Worksheets
If oSheet.ChartObjects.Count > 0 Then
oSheet.Activate
OriginalZoom = Windows(1).Zoom
Windows(1).Zoom = FORCED_ZOOM
For Each oChart In oSheet.ChartObjects
For Each mySrs In oChart.Chart.SeriesCollection
If Not ReplaceValueFound Then
OldFormula = mySrs.Formula
FormulaParts = Split(OldFormula, ",")
OldRow = RowToChange(FormulaParts(2))
ReplaceValueFound = True
End If
mySrs.Formula =
WorksheetFunction.Substitute(mySrs.Formula, OldRow, NewRow)
Next
oChart.Chart.Refresh
Next
Windows(1).Zoom = OriginalZoom
End If
Next
End If
'Application.ScreenUpdating = True
MsgBox "Done!", vbOKOnly, "Update Completed"
End Sub
Private Function RowToChange(ByVal SourceFormula As String) As String
'Runs once to figure out old row number
Dim CurrentCharacter As String
Dim ReturnValue As String
Dim ReverseCounter As Integer
For ReverseCounter = Len(SourceFormula) To 1 Step -1
CurrentCharacter = Mid(SourceFormula, ReverseCounter, 1)
If IsNumeric(CurrentCharacter) Then
ReturnValue = CurrentCharacter & ReturnValue
Else
Exit For
End If
Next ReverseCounter
RowToChange = ReturnValue
End Function
"joel" wrote:
>
> From you description the graphs are not off screen but just not getting
> refreshed. If the graphs were really off-screeen then the problem would
> also occur when you close and open the workbooks.
>
> Have you tried to manually perform a recalculte (F9). If you change
> worksheets and then come back to the the 1st worksheet does the charts
> get updated? Are there any other workbooks opened? Can you post the
> code so I can see where the ScreenUpdaing instructions are located.
>
>
> --
> joel
> ------------------------------------------------------------------------
> joel's Profile: 229
> View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=165537
>
> Microsoft Office Help
>
> .
>