Results 1 to 3 of 3

Thread: Get External Data Error

  1. #1
    Member
    Join Date
    Aug 2012
    Posts
    72
    Rep Power
    13

    Get External Data Error

    hi
    Summary: Every day a spreadsheet is extracted and saved in. Csv file with the name "Consolidated" followed by the date of extraction, for example, was saved well today "Consolidated 05-01". My macro just need to get the data from this spreadsheet that is saved in the same location on the server.

    Problem: It is debugging with error 1004, I have a slight idea of ​​what it is because it is not recognizing the leading zero in the worksheet name. For last month, from the day 22/12 (Day / Month), when I started to run the macro, never had this problem. Only from that year did you start debugging. So, I think the problem lies in the variable String or Integer.
    I thank you.
    Below is the code for programming.
    Code:
    Sub Organizando_Planilha()
    Dim ul As String
    Dim DIA As String
    Dim MES As Integer
    
    Sheets("Filas Encaminhadas").Select
    
    DIA = Day(Now())
    MES = Month(Now())
    
    Sheets("Filas Encaminhadas").Select
    With ActiveSheet.QueryTables.Add(Connection:= _
    "TEXT;\\Btgo3015\centro_solucoes$\OUVIDORIA\COE\SAULO EDUARDO\Relatórios\Consolidado " & DIA & "-" & MES & ".csv" _
    , Destination:=Range("$A$1"))
    .Name = "Consolidado " & DIA & "-" & MES
    .FieldNames = True
    .RowNumbers = False
    .FillAdjacentFormulas = False
    .PreserveFormatting = True
    .RefreshOnFileOpen = False
    .RefreshStyle = xlInsertDeleteCells
    .SavePassword = False
    .SaveData = True
    .AdjustColumnWidth = True
    .RefreshPeriod = 0
    .TextFilePromptOnRefresh = False
    .TextFilePlatform = 1252
    .TextFileStartRow = 1
    .TextFileParseType = xlDelimited
    .TextFileTextQualifier = xlTextQualifierDoubleQuote
    .TextFileConsecutiveDelimiter = False
    .TextFileTabDelimiter = True
    .TextFileSemicolonDelimiter = True
    .TextFileCommaDelimiter = False
    .TextFileSpaceDelimiter = False
    .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, _
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
    .TextFileTrailingMinusNumbers = True
    .Refresh BackgroundQuery:=False
    End With
    End Sub

  2. #2
    Senior Member
    Join Date
    Jun 2012
    Posts
    337
    Rep Power
    13
    Use:

    Code:
    sub M_snb()
      workbooks.open "\\Btgo3015\centro_solucoes$\OUVIDORIA\COE\SAULO EDUARDO\Relatórios\Consolidado " & format(date,"dd-mm") & ".csv"
    end sub

  3. #3
    Member
    Join Date
    Aug 2012
    Posts
    72
    Rep Power
    13
    Hi.

    excelent!!

    Solved!!

Similar Threads

  1. Difference Between 'On Error GoTo 0' And 'On Error GoTo -1'
    By Transformer in forum Familiar with Commands and Formulas
    Replies: 7
    Last Post: 07-02-2015, 04:07 PM
  2. Error when trying to use COMBO BOXES PADLOCK
    By marreco in forum Excel Help
    Replies: 2
    Last Post: 12-28-2012, 04:15 AM
  3. #Value Error in Working File
    By Suhail in forum Excel Help
    Replies: 2
    Last Post: 11-19-2012, 11:39 PM
  4. Swapping columns Error 2
    By jomili in forum Excel Help
    Replies: 1
    Last Post: 11-16-2012, 08:52 PM
  5. Excel Error
    By aarbuckle in forum Excel Help
    Replies: 5
    Last Post: 03-13-2012, 03:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •