Está en la página 1de 5

Macro repetir etiquetas

Dim REPETIR As Integer


REPETIR = Range("d1")
Range("A2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
For Q = 1 To REPETIR
Range("A65000").End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
Next Q
Application.CutCopyMode = False
Range("A1").Select
 
REPETIR = Range("d1")
Range("B2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
For Q = 1 To REPETIR
Range("B65000").End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
Next Q
Application.CutCopyMode = False
Range("A1").Select
End Sub

Quitar parpadeo en macro

Al inicio
Application.ScreenUpdating = False

Al final

Application.ScreenUpdating = true
CÓDIGO VBA PARA GENERAR CÓDIGOS QR:

#If VBA7 And Win64 Then

Private Declare PtrSafe Function URLDownloadToFile Lib "urlmon" _

Alias "URLDownloadToFileA" ( _

ByVal pCaller As LongPtr, _

ByVal szURL As String, _

ByVal szFileName As String, _

ByVal dwReserved As LongPtr, _

ByVal lpfnCB As LongPtr _

) As Long

#Else

#End If

Sub CrearQRMasivo()

Dim n&, i&

LimpiarImagenes

With wGenerador

n = .Range("A" & Rows.Count).End(xlUp).Row

For i = 4 To n

CrearQRIndividual .Range("A" & i)

Next
End With

End Sub

Sub CrearQRIndividual(Valor As Range)

Dim Link$, Ruta$, QR As Object

Dim lado&, izqui&, nTop&

'Descargo el código QR

If Valor.Value = Empty Then

Exit Sub

End If

Link = "http://chart.apis.google.com/chart?ch..." & Valor.Value & "&chld=H|0"

Ruta = ThisWorkbook.Path & "\chart.png"

URLDownloadToFile 0, Link, Ruta, 0, 0

'-----------------

'Ingreso la imagen

Set QR = ActiveSheet.Pictures.Insert(Ruta)

Kill Ruta

With wGenerador

nTop = .Range("B" & Valor.Row).Top

lado = .Range("B" & Valor.Row).Width

izqui = .Range("B" & Valor.Row).Left


With QR

.Top = nTop

.Width = lado

.Left = izqui

End With

.Range("B" & Valor.Row).RowHeight = lado

End With

'-----------------

End Sub

Sub LimpiarImagenes()

Dim imagen As Picture

For Each imagen In ActiveSheet.Pictures

imagen.Delete

Next

wGenerador.Range("A4", "A" & Rows.Count).RowHeight =


wGenerador.Range("A1").RowHeight

End Sub

Arreglar error

*Paso 1: Copian la descripción de la macro igual del link del video.


*Paso 2: La primera linea dice: #If VBA7 And Win64 Then (Pensando; creo que se
refiere al tipo de procesador que tiene su computadora); lo cambian a #If VBA7
And Win32 Then
*Paso 3: Se van a la parte donde aparece el link: Link =
“http://chart.apis.google.com/chart?ch…” & Valor.Value & “&chld=H|0” y lo
cambian por: Link = “http://chart.apis.google.com/chart?
cht=qr&chs=300×300&chl=” & Valor.Value & “&chld=H|0”
*Paso 4: No olviden cambiar la el nombre de la hoja donde procesaran la macro
a wGenerador como lo dice en el vídeo
Nota 1: Estuve intentando de varias maneras hacerlo funcionar y así como lo
explique pude solucionarlo. Espero les funcione.

También podría gustarte