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

#1 Héctor Miguel
05/09/2007 - 19:32 | Informe spam
hola, alex !

Mostrar la cita
modifica en *la macro* las referencias directas a *los nombres de las hojas*...
y sustituyela por alguna/s *variable/s* que pueda/n ser *tomada/s* de alguna parte en alguna hoja
y/o solicitadas al usuario [p.e. mediante in InputBox]

saludos,
hector.
#2 alex
05/09/2007 - 21:02 | Informe spam
y como le puedo hacer para el msj esque no se mucho de programacion, me
puedes ayudar

"Héctor Miguel" escribió:

Mostrar la cita
#3 alex
05/09/2007 - 22:26 | Informe spam
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 de la rep mexicana
de norte ejemplo tijuana, cd juarez, monterrey etc como le puedo hacer

espero me puedas ayudar
gracias

"alex" escribió:

Mostrar la cita
#4 Héctor Miguel
06/09/2007 - 03:14 | Informe spam
hola, alex !

Mostrar la cita
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.
#5 alex
11/09/2007 - 00:24 | Informe spam
esta es la macro que tengo:

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ó:

Mostrar la cita
Ads by Google
Search Busqueda sugerida