Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default CurrentRegion Failure. Please help!

This problem is still stumping me. Tom Ogilvy led me in the right direction
but my code is acting funny.

I have form code that adds data to a sheet and it taketh away as the user
requests. Each time a change is made, the sub below "Updateform" is called
to reinitialize the forms listboxes to reflect those change.

This sub works perfectly at all but one time. When I delete an item from the
sheet, say "A4", and when the sub below is called, the failure occurs when

rNameRange = Sheets("Names").Cells(1, 1).CurrentRegion.Columns(1)

is called. I get a 1004 error "Unable to get the current region property of
the range class". Tom suggested to make sure that the correct sheet is
activated as well as the cell "A1" is activated.

I have tried adding the following lines:

Range("A1"). select
selection.clear

To top that off, "activecell.address" was added to the watch window, and it
constantly reflects cell A4, even after the line range("A1").activate

I can't figure this out and it is holding me up from continuing. Please help
me. I can send all the code if you wish


Here goes:

Private Sub UpdateForm()

Dim rNameRange As Object
Dim CurrentRecord As Integer

ThisWorkbook.Sheets("Names").range("A1").Activate
'the next line is the problem although it works some
of the time
Set rNameRange = Sheets("Names").Cells(1, 1).CurrentRegion.Columns(1)
RepEntryBox.RowSource = rNameRange.Address
ListOfRepsBox.RowSource = rNameRange.Address

ThisWorkbook.Sheets("Stores").Activate

If Me.ListOfRepsBox.ListIndex < 0 Then
Me.RepStoreList.Clear
Exit Sub
End If

CurrentRecord = Me.ListOfRepsBox.ListIndex + 1

Set rNameRange = Sheets("Stores").Cells(1,
CurrentRecord).CurrentRegion.Columns(CurrentRecord )
Me.RepStoreList.RowSource = rNameRange.Address




End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default CurrentRegion Failure. Please help!

"John T Ingato" wrote in message
...

Private Sub UpdateForm()

Dim rNameRange As Object


Why not declare rNameRange as a Range object explicitly:

Dim rNameRange as Range



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default CurrentRegion Failure. Please help!

My mistake in not informin you. I have had it as Dim rNameRange as range

I just tried setting it as object today. I am trying anything at this point.



"Michael Hopwood" wrote in message
...
"John T Ingato" wrote in message
...

Private Sub UpdateForm()

Dim rNameRange As Object


Why not declare rNameRange as a Range object explicitly:

Dim rNameRange as Range





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
vlookup failure & ctrl-f failure? joemeshuggah Excel Discussion (Misc queries) 4 December 22nd 08 07:22 PM
currentregion flow23 Excel Discussion (Misc queries) 13 November 23rd 05 05:02 PM
Formula equivalent of CurrentRegion bdr200 Excel Worksheet Functions 1 June 14th 05 11:41 AM
CurrentRegion.copy maybe? Bob Phillips[_5_] Excel Programming 5 September 7th 03 10:20 PM


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