Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default Reference cells in a Hidden Worksheet for display in a UserForm

I have workbook which has a number of reference worksheets that need to be
hidden from the users view.

Those sheets need to be referred to by a UserForm as part of drop down lists
and other validations.

When trying to populate the combo box I get the following error....

Run-time error '1004':
Select method of Range class failed

Refer to the routine that is trying to create the list below

Public Sub SetAllLists()
'This routine will set all lists with the current values that are in place
at that time

'Create the Building Drop Down list for the Inspection form
Worksheets("Reference").Activate
Worksheets("Reference").Range("ReferenceBuildingHe adingStart").Select
If ActiveCell.Offset(1, 0).Value = "" Then
ActiveCell.Offset(1, 0).Select

'If there is only one entry in the List box then no need to sort or do
multiple selection
ElseIf ActiveCell.Offset(2, 0).Value = "" Then
ActiveCell.Offset(1, 0).Select

'If more than one entry then use the sort to refresh the list
Else
ActiveCell.Offset(1, 0).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Sort Key1:=Range("ReferenceBuildingHeadingStart"), _
Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End If

'Now reset the List of details shown on the page
Inspection.frmBuildingComboBox.RowSource =
ActiveWindow.RangeSelection.Address

End Sub

Is there any way to refer to data to worksheets that are hidden without
getting this error ?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default Reference cells in a Hidden Worksheet for display in a UserForm

I forgot to add that when the "Reference" worksheet is unhidden the routine
below works fine and displays the values in the Combo box

"scott56hannah" wrote:

I have workbook which has a number of reference worksheets that need to be
hidden from the users view.

Those sheets need to be referred to by a UserForm as part of drop down lists
and other validations.

When trying to populate the combo box I get the following error....

Run-time error '1004':
Select method of Range class failed

Refer to the routine that is trying to create the list below

Public Sub SetAllLists()
'This routine will set all lists with the current values that are in place
at that time

'Create the Building Drop Down list for the Inspection form
Worksheets("Reference").Activate
Worksheets("Reference").Range("ReferenceBuildingHe adingStart").Select
If ActiveCell.Offset(1, 0).Value = "" Then
ActiveCell.Offset(1, 0).Select

'If there is only one entry in the List box then no need to sort or do
multiple selection
ElseIf ActiveCell.Offset(2, 0).Value = "" Then
ActiveCell.Offset(1, 0).Select

'If more than one entry then use the sort to refresh the list
Else
ActiveCell.Offset(1, 0).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Sort Key1:=Range("ReferenceBuildingHeadingStart"), _
Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End If

'Now reset the List of details shown on the page
Inspection.frmBuildingComboBox.RowSource =
ActiveWindow.RangeSelection.Address

End Sub

Is there any way to refer to data to worksheets that are hidden without
getting this error ?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Reference cells in a Hidden Worksheet for display in a UserForm

You very rarely have to select/activate sheets/ranges to work with them.

I _think_ that this does what you want. (You really want a blank line in the
combobox if there is no data???)

Option Explicit
Public Sub SetAllLists()

Dim myRng As Range
Dim RefBldgHdStart As Range

'Create the Building Drop Down list for the Inspection form
With Worksheets("Reference")
Set RefBldgHdStart = .Range("ReferenceBuildingHeadingStart")
Set myRng = .Range(RefBldgHdStart.Cells(1), _
.Cells(.Rows.Count, RefBldgHdStart.Column).End(xlUp)) _
.Resize(, RefBldgHdStart.Columns.Count)
End With

With myRng
'I included the headers in the sort!
.Cells.Sort key1:=.Columns(1), order1:=xlAscending, header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

If .Columns(1).Cells.Count = 1 Then
'just use an empty row???
Set myRng = myRng.Offset(1, 0)
Else
'omit the headers
Set myRng = .Resize(.Rows.Count - 1).Offset(1, 0)
End If
End With

'Now reset the List of details shown on the page
Inspection.frmBuildingComboBox.RowSource = myRng.Address(external:=True)

'for my testing
'MsgBox myRng.Address(external:=True)

End Sub

scott56hannah wrote:

I have workbook which has a number of reference worksheets that need to be
hidden from the users view.

Those sheets need to be referred to by a UserForm as part of drop down lists
and other validations.

When trying to populate the combo box I get the following error....

Run-time error '1004':
Select method of Range class failed

Refer to the routine that is trying to create the list below

Public Sub SetAllLists()
'This routine will set all lists with the current values that are in place
at that time

'Create the Building Drop Down list for the Inspection form
Worksheets("Reference").Activate
Worksheets("Reference").Range("ReferenceBuildingHe adingStart").Select
If ActiveCell.Offset(1, 0).Value = "" Then
ActiveCell.Offset(1, 0).Select

'If there is only one entry in the List box then no need to sort or do
multiple selection
ElseIf ActiveCell.Offset(2, 0).Value = "" Then
ActiveCell.Offset(1, 0).Select

'If more than one entry then use the sort to refresh the list
Else
ActiveCell.Offset(1, 0).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Sort Key1:=Range("ReferenceBuildingHeadingStart"), _
Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End If

'Now reset the List of details shown on the page
Inspection.frmBuildingComboBox.RowSource =
ActiveWindow.RangeSelection.Address

End Sub

Is there any way to refer to data to worksheets that are hidden without
getting this error ?


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Reference cells in a Hidden Worksheet for display in a UserForm

hi
which line is generating the error?

Regards
FSt1

"scott56hannah" wrote:

I have workbook which has a number of reference worksheets that need to be
hidden from the users view.

Those sheets need to be referred to by a UserForm as part of drop down lists
and other validations.

When trying to populate the combo box I get the following error....

Run-time error '1004':
Select method of Range class failed

Refer to the routine that is trying to create the list below

Public Sub SetAllLists()
'This routine will set all lists with the current values that are in place
at that time

'Create the Building Drop Down list for the Inspection form
Worksheets("Reference").Activate
Worksheets("Reference").Range("ReferenceBuildingHe adingStart").Select
If ActiveCell.Offset(1, 0).Value = "" Then
ActiveCell.Offset(1, 0).Select

'If there is only one entry in the List box then no need to sort or do
multiple selection
ElseIf ActiveCell.Offset(2, 0).Value = "" Then
ActiveCell.Offset(1, 0).Select

'If more than one entry then use the sort to refresh the list
Else
ActiveCell.Offset(1, 0).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Sort Key1:=Range("ReferenceBuildingHeadingStart"), _
Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End If

'Now reset the List of details shown on the page
Inspection.frmBuildingComboBox.RowSource =
ActiveWindow.RangeSelection.Address

End Sub

Is there any way to refer to data to worksheets that are hidden without
getting this error ?

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
Display a hidden worksheet in Excel 2007? Andy F Excel Discussion (Misc queries) 1 May 24th 07 04:04 PM
Is it possible to display worksheets cells in a userform Trefor Excel Programming 11 May 17th 06 06:26 PM
Creating a varying UserForm using cells from a hidden worksheet Mort 62 Excel Programming 0 October 11th 05 02:46 PM
Reference a cell in a worksheet from a userform Adam Excel Programming 1 March 2nd 05 07:41 PM
Excel2000; display worksheet in userform Evan Excel Programming 0 January 6th 05 10:11 PM


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