vba

05/09/2007 - 15:58 por alex | Informe spam
espero me puedan ayudar

en una base de datos, inclui una macro la cual me permite jalar datos de
varias hojas a una sola, pero yo quiero utilizar esta macro para otros libros
(esta guardado en mi libro personal ) pero me genera u error porque mis hojas
de mis otros libros no tienen el mismo nombre, comopuedo hacer para que la
macro no se guie por el nombre, y pueda utilizar la macro para todos mis
libros

espero su respuesta

gracias

Preguntas similare

Leer las respuestas

#6 Héctor Miguel
11/09/2007 - 04:47 | Informe spam
hola, alex !

esta es la macro que tengo:



ok... ya pasaste la macro :)

y... el otro punto ???... puedes comentar algo al respecto ???... el que *decia*...
_____ *plis*... leelo detenidamente ya que no se puede adivinar lo que no se ha comentado :-(( _____

"2) comenta los nombres de las hojas para cada region [y el nombre de su libro o region correspondiente]"
" -> incluye si cada region tiene diferente numero de hojas-ciudades"
" -> comenta si las acciones de la macro [general ?] debe/puede aplicarse exactamente igual para todas las hojas"
" -> incluye cualquier otro detalle que no hayamos podido *ver* [desde este lado del mensaje] ;)"

saludos,
hector.

__ la consulta original __
esto lo hice dentro de un libro llamado centro, y quisiera utilizar esta
misma macro para un libro llamado sur donde el nombre de las hojas son las
ciudades que se encuentran en el sur como son merida, cuernavaca,puebla,etc,
y esta no la puedo utilizar para mi otro libro porque biene el nombre de las
hojas entonces como puedo hacerle???

espero me puedas ayudar

Sub concentrado()
'
' concentrado Macro
'

'
Columns("AA:EE").Select
ActiveSheet.Unprotect
Selection.EntireColumn.Hidden = False
Range("BH12:DB65").Select
Selection.Copy
ChDir "C:\Documents and Settings\admin.empresas\Escritorio"
Workbooks.Open Filename:= _
"C:\Documents and Settings\admin.empresas\Escritorio\concentrado
quincenal.xls"
Range("A2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Range("A12").Select
Selection.End(xlDown).Select
Range("A14").Select
ActiveWindow.LargeScroll Down:=1
Range("A44").Select
ActiveWindow.LargeScroll Down:=1
Range("A74").Select
ActiveWindow.LargeScroll Down:=-1
Range("A56").Select
Windows("nomina diario.xls").Activate
Sheets("guadalajara").Select
Columns("T:EE").Select
ActiveSheet.Unprotect
Selection.EntireColumn.Hidden = False
Range("BH12:DB65").Select
Selection.Copy
Windows("concentrado quincenal.xls").Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Range("A57").Select
ActiveWindow.LargeScroll Down:=1
Range("A87").Select
ActiveWindow.LargeScroll Down:=1
Range("A110").Select
Windows("nomina diario.xls").Activate
Sheets("irapuato").Select
ActiveSheet.Unprotect
Columns("AA:DX").Select
Selection.EntireColumn.Hidden = False
Range("BH12:DB65").Select
Selection.Copy
Windows("concentrado quincenal.xls").Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Range("A112").Select
ActiveWindow.LargeScroll Down:=1
Range("A142").Select
ActiveWindow.LargeScroll Down:=1
Range("A164").Select
Windows("nomina diario.xls").Activate
Sheets("culiacan").Select
ActiveSheet.Unprotect
Columns("Z:EA").Select
Selection.EntireColumn.Hidden = False
Range("BH12:DB65").Select
Selection.Copy
Windows("concentrado quincenal.xls").Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Range("A175").Select
ActiveWindow.LargeScroll Down:=1
Range("A205").Select
ActiveWindow.LargeScroll Down:=1
Range("A218").Select
Windows("nomina diario.xls").Activate
Sheets("celaya").Select

"Héctor Miguel" escribió:

hola, alex !

> por ejemplo uno de mis libros se llama centro y lleva todos los estados de la republica ubicados en el centro
> como por ejemplo toluca, puebla, etc y otro libro es norte y las hojas son los nombres de las ciudades... del norte
> ejemplo tijuana, cd juarez, monterrey etc como le puedo hacer ...

1) transcribe la macro en su siguiente mensaje

2) comenta los nombres de las hojas para cada region [y el nombre de su libro o region correspondiente]
-> incluye si cada region tiene diferente numero de hojas-ciudades
-> comenta si las acciones de la macro [general ?] debe/puede aplicarse exactamente igual para todas las hojas
-> incluye cualquier otro detalle que no hayamos podido *ver* [desde este lado del mensaje] ;)

saludos,
hector.



email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una pregunta AnteriorRespuesta Tengo una respuesta
Search Busqueda sugerida