Saltar al contenido
View in the app

A better way to browse. Learn more.

Ayuda Excel

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

NO ENTIENDO LA MACRO

publicado

Buenos días,
Intento crear una macro para que me guarde los datos.
En la hoja tengo 2 casos.
El caso1 lleva una macro que trabaja bien, pero en el caso2 no consigo hacer lo mismo que en el caso1.
Adjunto el libro por si hay alguien que me puede hechar una mano.
Gracias.
Jose

GUARDAR DATOS.xlsm

Featured Replies

publicado

Deja tus macros así:

Option Explicit

Sub Macro1()
Dim Fila As Long, H1 As Worksheet, H2 As Worksheet
'--
Application.ScreenUpdating = False 'Evita el parpadeo
Set H1 = Sheets("Sheet1")
Set H2 = Sheets("Sheet2")
'--
Fila = H2.Range("A" & Rows.Count).End(xlUp).Row + 1
H2.Range("A" & Fila) = H1.Range("B4")
H2.Range("B" & Fila) = H1.Range("B5")
H2.Range("C" & Fila) = H1.Range("B6")
H2.Range("D" & Fila) = H1.Range("B7")
H2.Range("A4:K" & Fila).Sort Key1:=H2.Columns("A")
H1.Range("B4:B7").ClearContents
H1.Range("B4").Select
End Sub
Sub Macro2()
Dim Fila As Long, H1 As Worksheet, H2 As Worksheet
'--
Application.ScreenUpdating = False 'Evita el parpadeo
Set H1 = Sheets("Sheet1")
Set H2 = Sheets("Sheet2")
'--
Fila = H2.Range("F" & Rows.Count).End(xlUp).Row + 1
H2.Range("F" & Fila) = H1.Range("E4")
H2.Range("G" & Fila) = H1.Range("G4")
H2.Range("H" & Fila) = H1.Range("I4")
H2.Range("I" & Fila) = H1.Range("E5")
H2.Range("J" & Fila) = H1.Range("G5")
H2.Range("K" & Fila) = H1.Range("I5")
H2.Range("F4:K" & Fila).Sort Key1:=H2.Columns("F")
H1.Range("E4:E5,G4:G5,I4:I5").ClearContents
H1.Range("E4").Select
End Sub

 

publicado
  • Autor

Muchas gracias Sr. Antoni.

Me ha servido de mucho su ayuda.

Le deseo un buen día.

Saludos,

Jose

 

publicado
  • Autor

Una pregunta.

Dim Fila As Long, H1 As Worksheet, H2 As Worksheet
'--
Application.ScreenUpdating = False 'Evita el parpadeo
Set H1 = Sheets("Sheet1")
Set H2 = Sheets("Sheet2")

¿Debo de entender que H1 y H2 son las hojas 1 y 2?

Gracias.

publicado

Hola @joselica

Set H1 = Sheets("Sheet1")

Investiga sobre Set... y de paso sobre With...End With

Y si, como dices, H1 es para que no escribas Sheets("Sheet1") solo H1 en tu código para que sea más corto, más entendible y más rápido.....

Saludos.

Editado el por Leopoldo Blancas

publicado
  • Autor

Muchas gracias Leopoldo pot tu aclaración.

Investigare en más adelante sebre el tema del Set que comentas.

Un saludos,

Jose

  • Silvia bloqueó este tema

Archivado

Este tema está ahora archivado y está cerrado a más respuestas.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.