hello maybe use something like this :
if the month is 1 number your string will be of size seven else if your string is size 8 we can say that the month would be 2 number.
This would work only if the day is set as 01 and not 1 for exemple ..
If Len("2572019") = 7 Then
MsgBox Left("2572019", 2) & "https://stackoverflow.com/" & Mid("2572019", 3, 1) & "https://stackoverflow.com/" & Right("2572019", 4)
end if
If Len("2572019") = 8 Then
Left("2572019", 2) & "https://stackoverflow.com/" & Mid("2572019", 3, 2) & "https://stackoverflow.com/" & Right("2572019", 4)
end if
Edit :
If Len(Cells(1,1).Value) = 7 Then
Cells(1,1).Value = Left(Cells(1,1).Value, 2) & "https://stackoverflow.com/" & Mid(Cells(1,1).Value, 3, 1) & "https://stackoverflow.com/" & Right(Cells(1,1).Value, 4)
end if
If Len(Cells(1,1).Value) = 8 Then
Cells(1,1).Value = Left(Cells(1,1).Value, 2) & "https://stackoverflow.com/" & Mid(Cells(1,1).Value, 3, 2) & "https://stackoverflow.com/" & Right(Cells(1,1).Value, 4)
end if
Edit 2 :
sub tryme()
Dim rng As range
Dim cell as range
Set rng = Application.InputBox("Select a range", "Selection" , Type:=8)
For Each cell in rng
If Len(cell.Value) = 7 Then
cell.Value = Left(cell.Value, 2) & "https://stackoverflow.com/" & Mid(cell.Value, 3, 1) & "https://stackoverflow.com/" & Right(cell.Value, 4)
end if
If Len(cell.Value) = 8 Then
cell.Value = Left(cell.Value, 2) & "https://stackoverflow.com/" & Mid(cell.Value, 3, 2) & "https://stackoverflow.com/" & Right(cell.Value, 4)
end if
next cell
end sub
11
solved i want number to be converted into dates by applying vba code