PDA

View Full Version : Using Userform Input to Run a certain command



viswadevan
06-13-2011, 06:33 PM
Hi Guys,

I've been working on a userform for days,
I want to use the input given in the userform to run a certain macro.
How do i activate it.

Scenario.
Userform Select Date and Shift
With given date and shift i need it to open an excel file from my desktop.

The following is the VBA command i'm using for manual run


Workbooks.Open Filename:= _
"C:\Documents and Settings\Viswa Devan Nair\Desktop\Macro Trail\New\Cell 2 Harddown Tracking File_June.xls"
Sheets("C Team 12-Jun").Select
Range("B22:P150").Select
Selection.Copy
Windows("HD tracking.xls").Activate
Sheets("Raw Data").Select
Range("A1").Select
ActiveSheet.Paste


I need the userform to select the following sheet that has been underlined.

Sorry can't include an image of the userform...

Gurus of macro... please help me...

thanks

GTO
06-13-2011, 06:46 PM
You can attach a workbook with the userform in it. Press the 'Go Advanced' button below the Quick Reply box. In the new window that opens, you will see a 'Manage Attachments' button...

viswadevan
06-13-2011, 06:52 PM
Hi GTO,

Thanks for the info...

This the Coding for the Userform


Private Sub UserForm_Initialize()
With ComboBox1
.AddItem "1"
.AddItem "2"
.AddItem "3"
.AddItem "4"
.AddItem "5"
.AddItem "6"
.AddItem "7"
.AddItem "8"
.AddItem "9"
.AddItem "10"
.AddItem "11"
.AddItem "12"
.AddItem "13"
.AddItem "14"
.AddItem "15"
.AddItem "16"
.AddItem "17"
.AddItem "18"
.AddItem "19"
.AddItem "20"
.AddItem "21"
.AddItem "22"
.AddItem "23"
.AddItem "24"
.AddItem "25"
.AddItem "26"
.AddItem "27"
.AddItem "28"
.AddItem "29"
.AddItem "30"
.AddItem "31"
End With
ComboBox1.Value = ""

With ComboBox2
.AddItem "Jan"
.AddItem "Feb"
.AddItem "Mar"
.AddItem "Apr"
.AddItem "May"
.AddItem "Jun"
.AddItem "Jul"
.AddItem "Aug"
.AddItem "Sep"
.AddItem "Oct"
.AddItem "Nov"
.AddItem "Dec"
End With
ComboBox2.Value = ""

With ComboBox3
.AddItem "2011"
End With
ComboBox3.Value = ""

With ComboBox4
.AddItem "A"
.AddItem "B"
.AddItem "C"
.AddItem "D"
End With
ComboBox4.Value = ""

End Sub