LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Sheets("Sheet9") Error

One way:

Dim ws As Worksheet
Dim wsLatest As Worksheet
Dim sTemp As String
Dim nMax As Long
For Each ws In Worksheets
sTemp = ws.Name
If sTemp Like "Sheet#*" Then
sTemp = Mid(sTemp, 6)
If IsNumeric(sTemp) Then
If CLng(sTemp) nMax Then _
nMax = CLng(sTemp)
End If
End If
Next ws
Set wsLatest = Worksheets("Sheet" & nMax)
ActiveChart.SetSourceData Source:=wsLatest.Range("A5")

In article ,
cesaoes wrote:

this is my line
ActiveChart.SetSourceData Source:=Sheets("Sheet9").Range("A5")
and i keep getting an error becuase, Sheets9 will stay like that, but every
time i run my macro, the sheet number where this is saved will be increasing
the next one will be
sheet10
sheet11....

how do i make it so it understand that has to run the latest one?

 
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
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
Error Help - Method "Range" of object "_Worksheet" failed. Alan Smith Excel Programming 3 March 15th 07 06:55 PM
What is Error "Method "Paste" of object "_Worksheet" failed? vat Excel Programming 7 February 17th 06 08:05 PM
Getting "compile error" "method or data member not found" on reinstall Bp Excel Programming 1 April 23rd 04 04:42 PM
"Path/File Access Error" on Sheets.Copy Nick Cranham Excel Programming 4 April 15th 04 01:41 PM


All times are GMT +1. The time now is 02:46 PM.

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

About Us

"It's about Microsoft Excel"