Hello
I have this code to copy data from listbox to sheet . in first column in listbox contains date will be like this DD/MM/YYYY, then will show DATE in 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 in listbox .... then should copy to column A like this 1,2,3.... but the problem will show like this 45155(DATEVALUE) .
so I want when copy data from listbox date in first column then should show date in column A , if when copy data from listbox numbers in first column then should show number in column A like this 1,2,3 .
Private Sub CommandButton1_Click()
With Sheets("sheet1")
.Range("a2").CurrentRegion.ClearContents
If OptionButton1.Value = True Then
.Range("A" & .Rows.Count).End(xlUp).Offset(0).Resize(ListBox1.ListCount, 6) = ListBox1.List
ElseIf OptionButton2.Value = True 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
also posted here
https://www.mrexcel.com/board/threads/change-column-from-date-to-number-format-and-opposite-after-copy-from-form.1243350/
thanks
Bookmarks