Thread: [Solved] Subscript out of range error
View Single Post
 
Old 01-12-2009, 02:56 AM
KHTAY KHTAY is offline
Novice
 
Join Date: Jan 2009
Posts: 3
KHTAY is on a distinguished road
Default

Hi. Thks for ur reply

User can actually retrieve data from each individual 'refresh' button for each sheet. But when user tries to retrieve data for all sheets (18 sheets) from the master sheet, user will encounter the problem.....

Sheet1 (Master sheet) -> 'Refresh All' button = retrieve data for all sheets (error!)
Sheet2 to Sheet18 -> each have a 'Refresh' button = retrieve data for each individual sheet (No error)

Below is a sample code for 1 of the refresh button. This sub will be tied up to a button on a sheet :

Sub RefreshKPI101()
Dim rs As Object
Dim sProc As String
Set rs = CreateObject("ADODB.Recordset")

sProc = "EXEC BUD_AF_GM '" + sBranch + "','" + sPeriod + "'"
rs.Open sProc, conn

Sheet10.Unprotect sPass
Sheet10.Range("A3").CopyFromRecordset rs
Sheet10.Protect sPass

End Sub

My doubt is why this code works for the button if i call from Sheet10.... It does not work if i call this sub from Sheet1....... One more funny issue is the above work for most PC in my compny but the error happens on a few.........

Pls help me. Thks.
Reply With Quote