# Extract date from text by code VBA



## sofas (Dec 27, 2022)

hello .I have this text in the column A how can i extract 05/12/2022 from within the text in column b
along the column

total selext frome 05/12/2022 to 06/12/2022


----------



## DanteAmor (Dec 27, 2022)

Use this formula:

Dante AmorAB12total selext frome 05/12/2022 to 06/12/202205/12/20223total selext frome 04/12/2022 to 10/12/202204/12/2022Hoja2Cell FormulasRangeFormulaB2:B3B2=MID(A2,SEARCH("??/??/????",A2),10)+0


----------



## sofas (Dec 27, 2022)

DanteAmor said:


> Use this formula:
> 
> Dante AmorAB12total selext frome 05/12/2022 to 06/12/202205/12/20223total selext frome 04/12/2022 to 10/12/202204/12/2022Hoja2Cell FormulasRangeFormulaB2:B3B2=MID(A2,SEARCH("??/??/????",A2),10)+0


Thank you. Can I convert it into code  vba?


----------



## DanteAmor (Dec 27, 2022)

sofas said:


> Can I convert it into code vba?



Your data starts in cell A2 going down, the results will be in cell B2 going down.


```
Sub Macro8()
  With Range("B2:B" & Range("A" & Rows.Count).End(3).Row)
    .Formula = "=MID(A2,SEARCH(""??/??/????"",A2),10)+0"
    .Value = .Value
  End With
End Sub
```


----------

