Userform Help........

mercmannick

Well-known Member
Joined
Jan 21, 2005
Messages
730
hi,

i am tryin to create a userform with 2 spinbuttons

and spin button 1 should be 1 to 52 for week no's
spinbutton 2 should be 1 to 5 for day no's

but i do not have any idea how to go about this i can create the form but how to code this is byond me

any of you peeps show me how please..............



Merc
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
the userform will be used to pick the sheet in code below (Week no , and Day no)


Rich (BB code):
   On Error GoTo ErrorHandler

    Application.ScreenUpdating = False
    Set TempBook = Workbooks.Add
    
    'Change line below to suit
    strMyBook = "I:\IMF stage starts wk 30.5.xls"     
    
    Workbooks.Open Filename:=strMyBook
    Range([A1], [IV1].End(xlToLeft)).Copy Destination:=TempBook.Sheets(1).Range("A1")
 
Upvote 0
Add 2 spinbuttons and 2 textboxes.

Set the Max property for the spinbuttons to 52 and 5.

Set the Min property for the spinbuttons to 1.

Add this code.
Code:
Private Sub SpinButton1_Change()
    TextBox1.Value = SpinButton1
End Sub
Private Sub SpinButton2_Change()
    TextBox2.Value = SpinButton2
End Sub
 
Upvote 0
Right click the buttons and select properties.

You should now see the property sheet for the control, where you can set the Max/Min property.

This is assuming you actually are using a userform.
 
Upvote 0
yes done that now norie

how can i get thstrMyBook = "I:\IMF stage starts wk 30.5.xls"


to change to the value of what is in the userform

ie if userform changes to 34.5 then to pick up file strMyBook = "I:\IMF stage starts wk 34.5.xls"


and how do i incorparate the userform to be called at the time when it needs it


Thanx

Merc
 
Upvote 0
Code:
Sub GetRedCells()
Dim strMyBook As String
Dim cell As Range
Dim TempBook As Workbook


   On Error GoTo ErrorHandler

    Application.ScreenUpdating = False
    Set TempBook = Workbooks.Add
    
    'Change line below to suit
    strMyBook = "I:\IMF stage starts wk 30.5.xls"     'ChDir "I:\"
    
    Workbooks.Open Filename:=strMyBook
    Range([A1], [IV1].End(xlToLeft)).Copy Destination:=TempBook.Sheets(1).Range("A1")
    
    ' Change Criteria1 to suit
    Range("D:D").AutoFilter Field:=4, Criteria1:="S03E"
    
    For Each cell In Range("E:E").SpecialCells(xlCellTypeVisible)
        If cell.Interior.ColorIndex = 3 Then _
            cell.EntireRow.Copy Destination:=TempBook.Sheets(1).Range("A65536").End(xlUp).Offset(1, 0)
    Next cell
    
    ActiveWorkbook.Close False
    Application.ScreenUpdating = True
Range("A:P").EntireColumn.AutoFit
Range("J1").EntireColumn.AutoFit
   On Error GoTo 0
   Exit Sub

ErrorHandler:

    MsgBox "Error: " & Err.Number & " (" & Err.Description & ")"
End Sub



above is whole code

Merc
 
Upvote 0

Forum statistics

Threads
1,217,367
Messages
6,136,143
Members
449,994
Latest member
Rocky Mountain High

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top