Cut a number of characters inside a VBA cell

Asked

Viewed 55 times

1

I have a VBA doubt!

Using a VBA code I imported data from a spreadsheet in excel to another spreadsheet. However, in column A, starting with cell A2 the copied information is in the following format "21/11/2020 7:00:00". I need to come up with a VBA code that cleans in these cells of this column the information 7:00:000 and maintains 21/11/2020, and I need it to repeat this for all data in column A and finish when there is no more data in that column. Below follows the code I am using to import the sheet data, I need to enter to this code.

Sub ImportarArquivo()

Dim caminho As Variant
Dim este As Workbook
Dim outro As Workbook

Application.ScreenUpdating = True

Application.DisplayAlerts = False

caminho = Application.GetOpenFilename

If caminho = False Then Exit Sub

Workbooks.Open caminho, , True
Set este = ThisWorkbook
Set outro = ActiveWorkbook

outro.Sheets(1).Range("A1").CurrentRegion.Copy
Planilha22.Range("A1").PasteSpecial

Columns("A:A").NumberFormat = "m/d/yyyy"

outro.Close False

 Columns("A:A").Select
    Selection.NumberFormat = "m/d/yyyy"
     
Sheets("Tela Inicial").Select

Application.ScreenUpdating = True

End Sub
  • You probably need to create a while to go line by line and use the Left (A1, 10) command where A1 will be your variable.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.