Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
shortcut key for switching sheets | Excel Discussion (Misc queries) | |||
Help on Add-in for switching between sheets | Excel Programming | |||
Controlling switching to other sheets | Excel Programming | |||
Switching between sheets in same window... | Excel Discussion (Misc queries) | |||
Switching Sheets | Excel Programming |