Home |
Search |
Today's Posts |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Brett,
Answers by Mike and Jacob are correct in that it is almost never necessary to select a range to process the data in those ranges. However, perhaps an explanation as to why you cannot select the range. My guess is that the code is in the Sheet1 Module and because of this, any reference to a range defaults to Sheet1 unless specified otherwise. Therefore use With / End With to tie the ranges to the required Parent sheet. Because you are selecting Range("E1") on Sheets("Times tables") after the ClearContents code I thought that maybe you have a valid reason to select in this case so that it is then ready for the user to continue with whatever needs to be done next and hense my real reason for this answer. Sub Button19_Click() Dim name As String Dim pswd As String name = Sheet1.TextBox1.Value pswd = Sheet1.TextBox2.Value If pswd = "Alphabet" Then Sheets("Record").Visible = True With Sheets("Times tables") .Select .Range("G3:G12").Select Selection.ClearContents .Range("E1").Select End With Sheet1.TextBox1.Value = "" Sheet1.TextBox2.Value = "" Else ActiveWorkbook.Close Application.Quit End If End Sub -- Regards, OssieMac |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Error handling error # 1004 Run-time error | Excel Programming | |||
Counting instances of found text (Excel error? Or user error?) | Excel Worksheet Functions | |||
Error Handling - On Error GoTo doesn't trap error successfully | Excel Programming | |||
Form Err.Raise error not trapped by entry procedure error handler | Excel Programming | |||
Automation Error, Unknown Error. Error value - 440 | Excel Programming |