Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default class range...select...(reserved for expert)

Example: (refer to help34.zip)

On running
..Range(sRng(i)).Select

ˇurunning error '1004':ˇv
ˇuClass Range ... Select ... method errorˇv

The problem may arise from this:

"db_rsImport", "db_rsExport" and "db_rsStock" are DYNAMIC RANGES
defined by 'offset' function
(for the purpose that in the three data-table, *only unlock* those
cells with data and the row just below the last record) .

How to solve it?

File Attached: http://www.excelforum.com/attachment.php?postid=330171 (help34.zip)

------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 176
Default class range...select...(reserved for expert)

Dear No-name,

Range(sRng(i)).Select

is improper syntax. sRng(i) is a range object, so you could use

sRng(i).Select

or

Range(sRng(i).Address).Select

I didn't open your attachment (and won't) but if you need more help
than that, post your code as text only.

HTH,
Bernie
MS Excel MVP

"active_x" wrote in message
...
Example: (refer to help34.zip)

On running
Range(sRng(i)).Select

ˇurunning error '1004':ˇv
ˇuClass Range ... Select ... method errorˇv

The problem may arise from this:

"db_rsImport", "db_rsExport" and "db_rsStock" are DYNAMIC RANGES
defined by 'offset' function
(for the purpose that in the three data-table, *only unlock* those
cells with data and the row just below the last record) .

How to solve it?

File Attached:

http://www.excelforum.com/attachment.php?postid=330171 (help34.zip)

------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from

http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default class range...select...(reserved for expert)

Scripts:

Sub Macro4()
Dim sRng(1 To 10) As String, sSht(1 To 4) As String
Dim i As Integer

sSht(1) = "main"
sSht(2) = "rsImport"
sSht(3) = "rsExport"
sSht(4) = "rsStock"

sRng(1) = "input_main"
sRng(2) = "db_rsImport"
sRng(3) = "db_rsExport"
sRng(4) = "db_rsStock"

For i = 1 To 4
With Sheets(sSht(i))

'lock ALL cells in ALL sht
Cells.Locked = True
Cells.FormulaHidden = True

'unlock specific cells in main, rsImport, rsExport and rsStock
Range(sRng(i)).Select '**the error arises
from this line
Selection.Locked = False

End With 'End With Sheets(sSht(i))
Next i

End Sub



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 176
Default class range...select...(reserved for expert)

Try changing

Range(sRng(i)).Select
Selection.Locked = False

to
..Range(sRng(i)).Locked = False
(There is no need to select the range first.)

Note the leading ., since you are using a with construct. This
assumes that nmaed range 1 is on named sheet 1, etc.

HTH,
Bernie
MS Excel MVP

"active_x" wrote in message
...
Scripts:

Sub Macro4()
Dim sRng(1 To 10) As String, sSht(1 To 4) As String
Dim i As Integer

sSht(1) = "main"
sSht(2) = "rsImport"
sSht(3) = "rsExport"
sSht(4) = "rsStock"

sRng(1) = "input_main"
sRng(2) = "db_rsImport"
sRng(3) = "db_rsExport"
sRng(4) = "db_rsStock"

For i = 1 To 4
With Sheets(sSht(i))

'lock ALL cells in ALL sht
Cells.Locked = True
Cells.FormulaHidden = True

'unlock specific cells in main, rsImport, rsExport and rsStock
Range(sRng(i)).Select '**the error arises
from this line
Selection.Locked = False

End With 'End With Sheets(sSht(i))
Next i

End Sub



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from

http://www.ExcelForum.com/



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 176
Default class range...select...(reserved for expert)

Note that you should also change

Cells.Locked = True
Cells.FormulaHidden = True
to
..Cells.Locked = True
..Cells.FormulaHidden = True

Otherwise, you are simply acting on the activesheet, and not the cells
of the 'withed' sheet.

HTH,
Bernie
MS Excel MVP

"Bernie Deitrick" wrote in message
...
Try changing

Range(sRng(i)).Select
Selection.Locked = False

to
.Range(sRng(i)).Locked = False
(There is no need to select the range first.)

Note the leading ., since you are using a with construct. This
assumes that nmaed range 1 is on named sheet 1, etc.

HTH,
Bernie
MS Excel MVP

"active_x" wrote in message
...
Scripts:

Sub Macro4()
Dim sRng(1 To 10) As String, sSht(1 To 4) As String
Dim i As Integer

sSht(1) = "main"
sSht(2) = "rsImport"
sSht(3) = "rsExport"
sSht(4) = "rsStock"

sRng(1) = "input_main"
sRng(2) = "db_rsImport"
sRng(3) = "db_rsExport"
sRng(4) = "db_rsStock"

For i = 1 To 4
With Sheets(sSht(i))

'lock ALL cells in ALL sht
Cells.Locked = True
Cells.FormulaHidden = True

'unlock specific cells in main, rsImport, rsExport and rsStock
Range(sRng(i)).Select '**the error arises
from this line
Selection.Locked = False

End With 'End With Sheets(sSht(i))
Next i

End Sub



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from

http://www.ExcelForum.com/







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
"Select method of Range class failed" Error Ayo Excel Discussion (Misc queries) 3 September 2nd 08 07:58 PM
Multiple Range Lookup Possible??? (Expert Level Question?) Naji Excel Discussion (Misc queries) 3 April 11th 08 04:15 PM
Run-Time error '1004' : Select method of Range class failed [email protected] Excel Discussion (Misc queries) 3 March 9th 07 01:36 PM
Run-time error "1004" Select method of range class failed Tallan Excel Discussion (Misc queries) 3 March 7th 07 05:22 PM
error 1004 Select method of Range class failed J.E. McGimpsey Excel Programming 1 September 12th 03 07:42 PM


All times are GMT +1. The time now is 01:22 AM.

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"