LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Userforms, switching sheets

My userform, which has been using data from sheet1, will give the user an
option to edit a list on another sheet, sheet2. A command button will open
different form that pertains to cells on sheet2. I'll use code similar to
this, below. Do I need to somehow make sheet2 the 'active sheet'? I found
this code here in this help newgroup, but it refers to things like,
LastRow = Range("A2").End(xlDown).Row
....how will my code know which sheet? I could maybe put
LastRow = Worksheets("sheet2").Range("A2").End(xlDown).Row
??? ...but then I'd have to go though and always put this? Can I just make
sheet2 the active sheet, and then skip the Worksheet("") code?

thanks,
Charlie


Option Explicit
Private LastRow As Long
Private Sub UserForm_Initialize()
LastRow = Range("A2").End(xlDown).Row
rownumber = 2
End Sub

Private Sub cmdFirst_Click()
rownumber.Text = "2"
GetData
End Sub

Private Sub cmdPrev_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
GetData
End Sub
Private Sub cmdNext_Click()
Dim r As Long
If IsNumeric(rownumber.Text) Then
r = rownumber
If r < LastRow Then
r = r + 1
Else
r = LastRow
End If
rownumber = r
GetData
End If
End Sub
Private Sub cmdLast_Click()
rownumber = LastRow
GetData
End Sub
Private Sub cmdSave_Click()

End Sub

Private Sub RowNumber_Change()
GetData
End Sub
Private Sub DisableSave()
cmdSave.Enabled = False
cmdClose.Enabled = False
End Sub
Private Function GetData()
' some code here to populate controls
End Function

 
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
shortcut key for switching sheets wb198 Excel Discussion (Misc queries) 2 February 1st 08 05:34 PM
Help on Add-in for switching between sheets muster Excel Programming 3 July 10th 06 02:34 PM
Controlling switching to other sheets Gordon Smith \(eMVP\) Excel Programming 5 June 15th 06 07:06 AM
Switching between sheets in same window... Kojones Excel Discussion (Misc queries) 1 July 16th 05 10:16 PM
Switching Sheets RogeR Excel Programming 1 June 10th 04 02:36 AM


All times are GMT +1. The time now is 06:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"