View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Zigball Zigball is offline
external usenet poster
 
Posts: 59
Default Problems with userform, refercencing code to worksheet

how, would you be able to elaborate on this.
JLGWhiz wrote:
I have never been able to get a hidden or very hidden worksheet to
participate in any activity until I unhide it.

"Zigball" wrote:

Hello ,
I am having trouble with the GetData Sub I suppose. This is used in my

userforms to scroll through rows and columns refering to a specific
worksheet. Example: userform1 inputs data into sheet1 then userform1
wants to getdata to display inside of the approiate fields in the
userform. there are four command buttons first, previous, next and
last. there is a text box named rownumber that displays the rownumber
that is being viewed. As before it will work if I am inside the
corresponding sheet but if that sheet is hidden or not selected it will

not work. Would you be able to figure this out? Here is an example of
the code that I have stored in the userform.

The main goal is to have it work while the sheet it is getting data
from is
veryhidden!

__________________________________________________ ___________________________
Public LastRow As Long
Private Sub GetData()
Dim r As Long
Dim r1 As Range, r2 As Range
Set r1 = Worksheets("sheet1").Range("A1:A100").CurrentRegio n
If IsNumeric(RowNumber.Text) Then
r = CLng(RowNumber.Text)
Else
ClearData
MsgBox "Illegal row number"
Exit Sub
End If
If r 1 And r <= LastRow Then
FirstName.Text = r1.Cells(r, 1)


ElseIf r = 2 Then
ClearData
Else
ClearData
MsgBox "Invalid row number"
End If
End Sub
__________________________________________________ _________________

Private Sub ClearData()
FirstName.Text = ""


End Sub
__________________________________________________ __________________

Private Sub RowNumber_Change()
GetData
End Sub
__________________________________________________ _______________

Private Sub First_Click()
RowNumber.Text = "2"
End Sub
__________________________________________________ ____________________

Private Sub Previous_Click()
Dim r As Long
If IsNumeric(RowNumber.Text) Then
r = CLng(RowNumber.Text)
r = r - 1
If r 1 And r <= LastRow Then
RowNumber.Text = FormatNumber(r, 0)
End If
End If
End Sub
__________________________________________________ ____________________

Private Sub Next1_Click()
Dim r As Long
If IsNumeric(RowNumber.Text) Then
r = CLng(RowNumber.Text)
r = r + 1
If r 1 And r <= LastRow Then
RowNumber.Text = FormatNumber(r, 0)
End If
End If
End Sub
__________________________________________________ ______________________

Private Function FindLastRow()
Dim r As Long
r = 2
Do While r < 65536 And Len(Cells(r, 1).Text) 0
r = r + 1
Loop
FindLastRow = r
End Function

__________________________________________________ ___________________