Consulting

Results 1 to 4 of 4

Thread: Help jump Columns

  1. #1
    VBAX Regular
    Joined
    Oct 2013
    Posts
    10
    Location

    Question Help jump Columns

    Hi all.
    I need a little help with my Sheets.

    Desktop.zip

    If you put the Sheets in your desktop and click in the button(TEST) in Plan1 Sheet ,
    will start to fill in the fields.

    However I would like each of the values were filled in the column painted in blue.

    Any doubt let me know.

    Ty all

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Sub BuscaSQL1()
        Dim ConecaoPlan As ADODB.Connection
        Dim rsConsulta As ADODB.Recordset
        Dim Caminho As String
        Dim Roda As Integer
        Dim sql As String
        
                      '/////////// - 2110 - ///////////'
        Caminho = ActiveWorkbook.Path & "\2110(2).xlsm"
    '
        ConecaoPlan.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=""" & Caminho & """;Extended Properties=Excel 8.0;"
        '";Extended Properties=Excel 12.0 Xml;HDR=YES;"Extended Properties=Excel 8.0
        ConecaoPlan.Open
        
        With Range("B10")
        
            Do While ActiveCell.Value <> "Total AR"
        
                sql = "Select * From [MontaBase$] Where Dado1 Like '" & ActiveCell.Value & "'"
                Set rsConsulta = ConecaoPlan.Execute(sql)
                        
                If rsConsulta.RecordCount > 0 Then
                
                    For Roda = 1 To 28 Step 5
                    
                        Cells(.Row, .Column + Roda).Value = rsConsulta!Dado2
                        rsConsulta.MoveNext
                    Next
                    End If
        
                rsConsulta.Close
            Loop
        End With
        
        Set ConecaoPlan = Nothing
        Set rsConsulta = Nothing
    End Sub
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    Oct 2013
    Posts
    10
    Location

    Thumbs up

    Quote Originally Posted by xld View Post
    Sub BuscaSQL1()
        Dim ConecaoPlan As ADODB.Connection
        Dim rsConsulta As ADODB.Recordset
        Dim Caminho As String
        Dim Roda As Integer
        Dim sql As String
        
                      '/////////// - 2110 - ///////////'
        Caminho = ActiveWorkbook.Path & "\2110(2).xlsm"
    '
        ConecaoPlan.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=""" & Caminho & """;Extended Properties=Excel 8.0;"
        '";Extended Properties=Excel 12.0 Xml;HDR=YES;"Extended Properties=Excel 8.0
        ConecaoPlan.Open
        
        With Range("B10")
        
            Do While ActiveCell.Value <> "Total AR"
        
                sql = "Select * From [MontaBase$] Where Dado1 Like '" & ActiveCell.Value & "'"
                Set rsConsulta = ConecaoPlan.Execute(sql)
                        
                If rsConsulta.RecordCount > 0 Then
                
                    For Roda = 1 To 28 Step 5
                    
                        Cells(.Row, .Column + Roda).Value = rsConsulta!Dado2
                        rsConsulta.MoveNext
                    Next
                    End If
        
                rsConsulta.Close
            Loop
        End With
        
        Set ConecaoPlan = Nothing
        Set rsConsulta = Nothing
    End Sub

    Thanks very much . It Works like a charm.

  4. #4
    VBAX Regular
    Joined
    Oct 2013
    Posts
    10
    Location

    Question

    Let's think there is already filled data in this spreadsheet (Annex) and this new information will be filled by the macro, keeping the information that was already filled.
    Any idea how can I do this?

    Desktop.zip

    Thanks again.

Posting Permissions

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