Ver Mensaje Individual
  #1 (permalink)  
Antiguo 23/09/2008, 21:43
molavar
 
Fecha de Ingreso: septiembre-2008
Mensajes: 3
Antigüedad: 15 años, 8 meses
Puntos: 0
Problemas con una Macro en Excell

Buenas Noches...me gustaria me pudieran ayudar con esta macro...
tengo problemas en esta parte:

With Hoja3.QueryTables.Add(Connection:="ODBC;DSN=Excel Files;ActiveWorkBook", Destination:=Range("C3"))

esta es la macro completa, y lo que trata de hacer es conectarse con otra hoja del mismo libro excell.........ojala me puedan ayudar..muchas gracias

Sub Prueba()
'
' Prueba Macro
' Macro grabada el 12/09/2008 por Administrador

Sheets("Tabla").Range("C4:BL60000").Clear

Dim zona_nueva, segmento, grupo, str As String
zona_nueva = ActiveSheet.Cells(1, 1)
segmento = ActiveSheet.Cells(3, 1)
grupo = ActiveSheet.Cells(2, 1)

If grupo = "Clientes" Then
str = "select `Base$`.nom_suc,`Base$`.CtesCC FROM `Base$` where zona_nueva= '" & zona_nueva & "' and segmento ='" & segmento & "' order by `Base$`.nom_suc asc"
End If

With Hoja3.QueryTables.Add(Connection:="ODBC;DSN=Excel Files;ActiveWorkBook", Destination:=Range("C3"))

.CommandText = Array(str)
.Name = "CuadrodeMando"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With

End Sub