Jambi46n2
Active Member
- Joined
- May 24, 2016
- Messages
- 260
- Office Version
- 365
- Platform
- Windows
Hello,
I have created a code in VBA to convert dates from YMD to MDY as a Ribbon (Excel 2007)
Problem is the code doesn't work unless the user specifies the Cell of the Header for the Column to be Converted. I would like to place a Message Box if someone typed C2 instead of C1 for example. So I can prompt the user and remind them to select a Column Header.
Here's my code that works perfectly fine with an exception to having a Message Box Error.
As always thanks for your help!
I have created a code in VBA to convert dates from YMD to MDY as a Ribbon (Excel 2007)
Problem is the code doesn't work unless the user specifies the Cell of the Header for the Column to be Converted. I would like to place a Message Box if someone typed C2 instead of C1 for example. So I can prompt the user and remind them to select a Column Header.
Here's my code that works perfectly fine with an exception to having a Message Box Error.
As always thanks for your help!
Code:
Sub Convert_Dates_YMD_To_MDY(control As IRibbonControl)'
' Convert_Dates_YMD_To_MDY
Dim aRange As Range
On Error Resume Next
Set aRange = Application.InputBox(prompt:="Enter The First Cell of Column to Convert (Example C1)", Type:=8)
If aRange Is Nothing Then
MsgBox "Operation Cancelled"
Else
aRange.Select
End If
Range(Selection, Selection.EntireColumn).Select
Selection.TextToColumns Destination:=aRange, DataType:=xlDelimited, _
TextQualifier:=xlNone, ConsecutiveDelimiter:=False, Tab:=False, _
Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
:=Array(1, 5), TrailingMinusNumbers:=True
End Sub