Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default Error message when I open any other excel file

Hi all, I have macro below in Worksheet Module. It works fine but
when ever I open any other excel file at the same time when I got
current file (in which I got the below macro) opened, I get error
message pop up saying "Run-time error '9': Subscript out of Range"
Please can any friend can help that how can i get rid of this error
message.

Private Sub Worksheet_Calculate()
Dim SHT As Worksheet
Set SHT = Sheets("Template")
If Range("C6").Value = "GD" Then
SHT.Shapes("BACKTEMP").Width = 398
SHT.Shapes("NUMBERS").Visible = True
SHT.Shapes("ACCRUE").Visible = True
Me.TextBox3.Visible = True
Me.ComboBox2.ListFillRange = "S33:S43"
Me.ComboBox2.ListRows = 11
Else
SHT.Shapes("NUMBERS").Visible = False
SHT.Shapes("ACCRUE").Visible = False
Me.TextBox3.Visible = False
SHT.Shapes("BACKTEMP").Width = 302
Me.ComboBox2.ListFillRange = "S33:S45"
Me.ComboBox2.ListRows = 13
End If
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Error message when I open any other excel file

Specify what workbook contains the Template sheet:

Set SHT = me.parent.Sheets("Template")

Me is the worksheet that owns the code.
Me.Parent is the workbook that owns the worksheet that owns the code.



K wrote:

Hi all, I have macro below in Worksheet Module. It works fine but
when ever I open any other excel file at the same time when I got
current file (in which I got the below macro) opened, I get error
message pop up saying "Run-time error '9': Subscript out of Range"
Please can any friend can help that how can i get rid of this error
message.

Private Sub Worksheet_Calculate()
Dim SHT As Worksheet
Set SHT = Sheets("Template")
If Range("C6").Value = "GD" Then
SHT.Shapes("BACKTEMP").Width = 398
SHT.Shapes("NUMBERS").Visible = True
SHT.Shapes("ACCRUE").Visible = True
Me.TextBox3.Visible = True
Me.ComboBox2.ListFillRange = "S33:S43"
Me.ComboBox2.ListRows = 11
Else
SHT.Shapes("NUMBERS").Visible = False
SHT.Shapes("ACCRUE").Visible = False
Me.TextBox3.Visible = False
SHT.Shapes("BACKTEMP").Width = 302
Me.ComboBox2.ListFillRange = "S33:S45"
Me.ComboBox2.ListRows = 13
End If
End Sub


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default Error message when I open any other excel file

On May 21, 3:31*pm, Dave Peterson wrote:
Specify what workbook contains the Template sheet:

Set SHT = me.parent.Sheets("Template")

Me is the worksheet that owns the code.
Me.Parent is the workbook that owns the worksheet that owns the code.





K wrote:

Hi all, *I have macro below in Worksheet Module. *It works fine but
when ever I open any other excel file at the same time when I got
current file (in which I got the below macro) opened, I get error
message pop up saying "Run-time error '9': Subscript out of Range"
Please can any friend can help that how can i get rid of this error
message.


Private Sub Worksheet_Calculate()
Dim SHT As Worksheet
Set SHT = Sheets("Template")
If Range("C6").Value = "GD" Then
SHT.Shapes("BACKTEMP").Width = 398
SHT.Shapes("NUMBERS").Visible = True
SHT.Shapes("ACCRUE").Visible = True
Me.TextBox3.Visible = True
Me.ComboBox2.ListFillRange = "S33:S43"
Me.ComboBox2.ListRows = 11
Else
SHT.Shapes("NUMBERS").Visible = False
SHT.Shapes("ACCRUE").Visible = False
Me.TextBox3.Visible = False
SHT.Shapes("BACKTEMP").Width = 302
Me.ComboBox2.ListFillRange = "S33:S45"
Me.ComboBox2.ListRows = 13
End If
End Sub


--

Dave Peterson- Hide quoted text -

- Show quoted text -


Thanks lot Dave
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
After File Open View Preview get error message big-bob Excel Discussion (Misc queries) 4 November 3rd 06 08:24 PM
Error message when using Excel to open text file orutulsa Excel Discussion (Misc queries) 2 March 14th 06 06:10 PM
File won't open. Error message "too many different cell formats" baytulsa Excel Worksheet Functions 1 September 12th 05 07:21 PM
Trying to open Excel/Word files error message "Unable to read file RobM Excel Discussion (Misc queries) 1 February 7th 05 08:11 PM
open file file then error message Piroon Saetang Excel Discussion (Misc queries) 1 February 4th 05 12:05 AM


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