I created a sample worksheet for my problem.
Output.xls is wbDest the code for my combobox is
Private Sub Userform_Initialize()
Dim i As Integer
For i = 1 To 12
ComboBox1.AddItem MonthName(i)
Next i
End Sub
Questions:
1. But this only shows months, what if I want to make it day-month-year format?
2. Below is my copy paste code, How will I modify this so that the filename of the source(wbSrc) will depend on the date that I will choose in the combo box.
Option Explicit
Sub CopyTo()
'Declare all variables - always a good idea!
Dim lastrow As Long
Dim wbSrc As Worksheet
Dim wbDest As Worksheet
'Set to FALSE for speed/flicker
Application.ScreenUpdating = False
'Type in once!
Set wbDest = Workbooks("Output.xls").Sheets("Sheet1")
Set wbSrc = Workbooks("12-May-10.xls").Sheets("Data")
'Get last row of data
lastrow = wbDest.Cells(Rows.Count, "A").End(xlUp).Row
'if lastrow > 1 then add 1 to equal first BLANK row
If lastrow > 1 Then
lastrow = lastrow + 1
End If
'Use created objects not looooooooooooong.......names
' also avoids typing names repeatedly: too many chances for 'tpyos'!
With wbSrc
.Range("A2:A9000").Copy
wbDest.Cells(lastrow, "A").PasteSpecial Paste:=xlPasteValues
.Range("B2:B9000").Copy
wbDest.Cells(lastrow, "B").PasteSpecial Paste:=xlPasteValues
.Range("C2:C9000").Copy
wbDest.Cells(lastrow, "C").PasteSpecial Paste:=xlPasteValues
End With
'Cleanup
Set wbSrc = Nothing
Set wbDest = Nothing
'Reset
Application.ScreenUpdating = True
End Sub
Thanks in advance!!!