Excel VBA application appeler copy 2 plages

Amis, je suis très pauvre en programmation, mais peut-être quelqu'un est-il disposé à aider.

Ma table de calcul contient 18 plages et 2 en-têtes différents dans la zone protégée. J'ai besoin de copyr et de combiner 1 en-tête et 1 gamme à l'autre, zone non protégée. L'user doit appuyer sur un button et la macro apporte des données à une nouvelle position où elle peut être collée.

Pour l'utilisation du button, j'ai une application.caller pour cacher et afficher les lignes. Je pense que c'est un bon début. J'ai également une macro de copy pour 1 set de plages. J'aimerais combiner ces 2 dans une nouvelle macro.

Sub Macro_copy_RIVA1() Range("RHEAD").Copy Range("RIVA1").Copy Application.Goto Reference:="R1120C2" Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Application.CutCopyMode = False Selection.Cut End Sub 

Mon appelant d'application pour les lignes de cacher / afficher est (grâce à Stackoverflow)

 Sub ShowHideRows() Dim arr 'split the calling button name into an array ' (array will be zero-based) arr = Split(Application.Caller, "_") '**EDIT** check array is expected size... If UBound(arr) <> 3 Then Exit Sub If IsNumeric(arr(1)) And IsNumeric(arr(2)) Then With ActiveSheet ' "Me" if the code is in the sheet module, else "ActiveSheet" .Unprotect Password:="" 'arr(1) determines start row 'arr(2) determines # of rows 'arr(3) determines if rows are hidden or not .Cells(arr(1), 1).Resize(arr(2), 1).EntireRow.Hidden = (arr(3) = "H") .Protect Password:="" End With End If End Sub` 

Mes gammes sont appelées:

Entête:

  • RHEAD1
  • RHEAD2

Gammes:

  • RIVA1
  • RIVA2
  • RIVA3
  • …..
  • RIVA6
  • RMVA1
  • RMVA2
  • …..
  • RMVA12

Nom proposé du button: btn_RHEAD1_RIVA1 ou btn_RHEAD2_RMVA12

Comment puis-je exécuter une macro à partir d'un appelant d'application qui effectue la tâche de copy? Merci