Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Error 9 - Subscript out of range

I am using a form for the users to fill in. The values filled in by
user is populated in a sheet when the user clicks submit button . This
sheet alone is emailed using the mail system.

This code works for all except one user. That user keeps getting Error
9 ( subscript out of range)/ 91 (object variable or with block
variable not set) and the debug cursor points to worksheet select
code.

Workbooks("Form.xls").Sheets("sheet2").Activate

'Delete values in column B if there is any data
Columns("B:B").Select
Selection.ClearContents

Range("B1").Select
ActiveCell.Value = txtname.Value

Not sure what is wrong. May i request your help.

Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Error 9 - Subscript out of range

with Workbooks("Form.xls").Sheets("sheet2")
.Columns("B:B").ClearContents
.Range("B1").Value = txtname.Value
End WIth

this code is tidier anyway ;)
presumably the workbook name is correct and the sheet name too?






"jerry" wrote:

I am using a form for the users to fill in. The values filled in by
user is populated in a sheet when the user clicks submit button . This
sheet alone is emailed using the mail system.

This code works for all except one user. That user keeps getting Error
9 ( subscript out of range)/ 91 (object variable or with block
variable not set) and the debug cursor points to worksheet select
code.

Workbooks("Form.xls").Sheets("sheet2").Activate

'Delete values in column B if there is any data
Columns("B:B").Select
Selection.ClearContents

Range("B1").Select
ActiveCell.Value = txtname.Value

Not sure what is wrong. May i request your help.

Thanks


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Error 9 - Subscript out of range

Subscript out of range means that you are asking the code to take you to a
place that does not exist or can not be accessed. Assuming your problem is on
this line

Workbooks("Form.xls").Sheets("sheet2").Activate

Then my guess would be
1. The workbook name is changed
2. The sheet name is changed
3. The sheet is hidden
4. Form.xls is not the active workbook when this code is executed.
--
HTH...

Jim Thomlinson


"jerry" wrote:

I am using a form for the users to fill in. The values filled in by
user is populated in a sheet when the user clicks submit button . This
sheet alone is emailed using the mail system.

This code works for all except one user. That user keeps getting Error
9 ( subscript out of range)/ 91 (object variable or with block
variable not set) and the debug cursor points to worksheet select
code.

Workbooks("Form.xls").Sheets("sheet2").Activate

'Delete values in column B if there is any data
Columns("B:B").Select
Selection.ClearContents

Range("B1").Select
ActiveCell.Value = txtname.Value

Not sure what is wrong. May i request your help.

Thanks


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
Subscript out of range error Guy Normandeau Excel Programming 2 July 31st 06 10:03 PM
Runtime Error - Subscript out of range despite On Error statement DoctorG Excel Programming 3 July 28th 06 03:56 PM
Subscript out of range error - save copy error bg18461[_16_] Excel Programming 2 June 13th 06 04:53 PM
Subscript out of range error - save copy error bg18461[_15_] Excel Programming 1 June 13th 06 04:36 PM
Type Mismatch error & subscript out of range error Jeff Wright[_2_] Excel Programming 3 May 14th 05 07:14 PM


All times are GMT +1. The time now is 03:27 AM.

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"