Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Problems with userform, refercencing code to worksheet

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

__________________________________________________ ___________________

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Problems with userform, refercencing code to worksheet

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

__________________________________________________ ___________________


  #3   Report Post  
Posted to microsoft.public.excel.programming
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

__________________________________________________ ___________________



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
Code in userform/worksheet vs. in Module davegb Excel Programming 2 June 19th 06 04:17 PM
userform problems [email protected] Excel Programming 0 March 7th 05 08:56 PM
userform problems [email protected] Excel Programming 0 February 16th 05 06:10 PM
UserForm Problems Joe[_27_] Excel Programming 2 October 21st 03 12:52 PM
More UserForm problems Les[_4_] Excel Programming 2 July 23rd 03 12:29 AM


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