ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Unexplicable error (https://www.excelbanter.com/excel-programming/439949-unexplicable-error.html)

Ayo

Unexplicable error
 
I have this error occuring everytime I try to runnthe code. "Unable to set
the ShowDetail property of the range class"
I have a button with this sub:
Private Sub cmdMarket_Click()
Application.ScreenUpdating = False
Application.EnableEvents = False
Me.Rows("2:60").EntireRow.Hidden = False
ActiveWindow.ScrollRow = 2
ActiveSheet.Range("4:31").EntireRow.Hidden = True
Me.Range("C37") = "ALL VENDORS"
Me.Range("C32") = Me.Range("C4")

Me.Range("D39:H58").Select
Selection.Replace What:="$A$3:$A$712=$B1",
Replacement:="$B$3:$B$712=$C$32"
Selection.Replace What:="$A$3:$A$712<""""",
Replacement:="$B$3:$B$712=$C$32"
Me.Range("A3").Select
Me.Calculate
Application.EnableEvents = True
Call groupMarket
End Sub

The groupMarket has this sub:
Sub groupMarket()
Range("40:40").Rows.ShowDetail = False
Range("42:42").Rows.ShowDetail = False
Range("44:44").Rows.ShowDetail = False
Range("46:46").Rows.ShowDetail = False
Range("48:48").Rows.ShowDetail = False
Range("50:50").Rows.ShowDetail = False
Range("52:52").Rows.ShowDetail = False
Range("54:54").Rows.ShowDetail = False
Range("56:56").Rows.ShowDetail = False
Range("58:58").Rows.ShowDetail = False
End Sub

Everytime I click the button, the execution stops at the first line in
groupMarket(). When I click debug and click the run button in VBE, the
execution continues and the codes run fine. I can't understand why it is
stopping at "Range("40:40").Rows.ShowDetail = False" every single time.

Any ideas?

joel[_723_]

Unexplicable error
 

the code doesn't know which sheet you are refering to. the code has
been running with the focus on the userform and the the code doesn't
know which sheet in the workbook you want to work with.


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=182456

Microsoft Office Help


OssieMac

Unexplicable error
 
Try the following. Note the dot in front of range to tie it to the With

Sub groupMarket()
'Edit "Sheet1" to your sheet name
With Sheets("Sheet1")
.Range("40:40").Rows.ShowDetail = False
.Range("42:42").Rows.ShowDetail = False
.Range("44:44").Rows.ShowDetail = False
.Range("46:46").Rows.ShowDetail = False
.Range("48:48").Rows.ShowDetail = False
.Range("50:50").Rows.ShowDetail = False
.Range("52:52").Rows.ShowDetail = False
.Range("54:54").Rows.ShowDetail = False
.Range("56:56").Rows.ShowDetail = False
.Range("58:58").Rows.ShowDetail = False
End With
End Sub

--
Regards,

OssieMac


"Ayo" wrote:

I have this error occuring everytime I try to runnthe code. "Unable to set
the ShowDetail property of the range class"
I have a button with this sub:
Private Sub cmdMarket_Click()
Application.ScreenUpdating = False
Application.EnableEvents = False
Me.Rows("2:60").EntireRow.Hidden = False
ActiveWindow.ScrollRow = 2
ActiveSheet.Range("4:31").EntireRow.Hidden = True
Me.Range("C37") = "ALL VENDORS"
Me.Range("C32") = Me.Range("C4")

Me.Range("D39:H58").Select
Selection.Replace What:="$A$3:$A$712=$B1",
Replacement:="$B$3:$B$712=$C$32"
Selection.Replace What:="$A$3:$A$712<""""",
Replacement:="$B$3:$B$712=$C$32"
Me.Range("A3").Select
Me.Calculate
Application.EnableEvents = True
Call groupMarket
End Sub

The groupMarket has this sub:
Sub groupMarket()
Range("40:40").Rows.ShowDetail = False
Range("42:42").Rows.ShowDetail = False
Range("44:44").Rows.ShowDetail = False
Range("46:46").Rows.ShowDetail = False
Range("48:48").Rows.ShowDetail = False
Range("50:50").Rows.ShowDetail = False
Range("52:52").Rows.ShowDetail = False
Range("54:54").Rows.ShowDetail = False
Range("56:56").Rows.ShowDetail = False
Range("58:58").Rows.ShowDetail = False
End Sub

Everytime I click the button, the execution stops at the first line in
groupMarket(). When I click debug and click the run button in VBE, the
execution continues and the codes run fine. I can't understand why it is
stopping at "Range("40:40").Rows.ShowDetail = False" every single time.

Any ideas?



All times are GMT +1. The time now is 07:50 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com