Hello
I have this code to copy data from listbox to sheet . in first column contains date based on selected item from combobox when populate date will be like this DD/MM/YYYY then will show column A and it's ok ,but my problem when select optionbutton1 or optionbutton2 and populate numbers in first column like this 1,2,3 .... then should copy to column A like this 1,2,3.... but the problem will show like this 45155 .
so I want when copy data from listbox date in first column then should show date in column A is , if when copy data from listbox numbers in first column then should show number in column A .
I have this code to copy data from listbox to sheet . in first column contains date based on selected item from combobox when populate date will be like this DD/MM/YYYY then will show column A and it's ok ,but my problem when select optionbutton1 or optionbutton2 and populate numbers in first column like this 1,2,3 .... then should copy to column A like this 1,2,3.... but the problem will show like this 45155 .
so I want when copy data from listbox date in first column then should show date in column A is , if when copy data from listbox numbers in first column then should show number in column A .
VBA Code:
Private Sub CommandButton2_Click()
With Sheets("sheet1")
.Range("a2").CurrentRegion.ClearContents
If OptionButton1.Value = True Or OptionButton2.Value = True Then
.Range("A" & .Rows.Count).End(xlUp).Offset(0).Resize(ListBox1.ListCount, 6) = ListBox1.List
ElseIf ComboBox1.Value <> "" Then
.Range("A" & .Rows.Count).End(xlUp).Offset(0).Resize(ListBox1.ListCount, 6) = ListBox1.List
.Columns(1).NumberFormat = " General"
End If
End With
Sheets("sheet1").Range("a1").CurrentRegion.PrintOut
End Sub