Concatener par Macros

teodormircea

XLDnaute Occasionnel
Bonjour le Forum

Je voudrais remplacer cette formule , ="*"& cellule &"*" avec une macros.

comme celle ci mais çà marche pas
Code:
Sub Conca()
Dim X, Y As Integer
If MsgBox("Code Y Assets a REVOIR", vbYesNo, "Continuer pour MARQUER") = vbYes Then
'xcl = 2 'ici j'indique la variable qui n'était pas renseignée dans ta macro
X = InputBox("SOURCE", "SOURCE")
Y = InputBox("TARGET", "TARGET")

k = Range(Cells(Rows.Count, X).Address).End(xlUp).Row - 1

i = Range(Cells(Rows.Count, Y).Address).End(xlUp).Row - 1

Range(Cells(2, Y), Cells(i, Y)) = Range(Cells(2, X), Cells(k, X))
End If
'c'est tout sans boucle
End Sub
Un peux de lumière:p
 

kjin

XLDnaute Barbatruc
Re : Concatener par Macros

Bonjour,
Commence par modifier les variables X et Y, parce que de fait elles sont au format texte et ça ne peut pas fonctionner
Code:
X = CLng(InputBox("SOURCE", "SOURCE"))
Y = CLng(InputBox("TARGET", "TARGET"))
Pour le reste je n'ai pas compris ce que tu veux faire
A+
kjin
 

Caillou

XLDnaute Impliqué
Re : Concatener par Macros

une petite remarque si je puis me permettre,

Dans la ligne
Dim X, Y As Integer
seule la variable Y est déclarée en Integer (X est variant)
pour déclarer les 2 en Integer, il faut écrire :
Dim X As Integer, Y As Integer

Caillou
 

teodormircea

XLDnaute Occasionnel
Re : Concatener par Macros

Oui,
Code:
Sub Conca()
Dim X, Y As Integer

X = InputBox("SOURCE", "SOURCE")
Y = InputBox("TARGET", "TARGET")

k = Range(Cells(Rows.Count, X).Address).End(xlUp).Row - 1

i = Range(Cells(Rows.Count, Y).Address).End(xlUp).Row - 1

Range(Cells(2, Y), Cells(i, Y)) = "*"&Range(Cells(2, X), Cells(k, X))&"*"


End Sub
voila ca marche toujours pas , la je pense que c'est ma méthode qui est pas bonne
 

teodormircea

XLDnaute Occasionnel
Re : Concatener par Macros

Code:
Sub Conca()
 
       Dim X As Integer
       Dim Y As Integer
       Dim Z As Integer
       Dim i As Integer
       
       
       X = Application.InputBox(prompt:="Source Column ", Title:="Insert Column Number", Type:=1)
       If (X < 1) + (X > Columns.Count) Then Exit Sub
       LastRow = ActiveSheet.Cells(Rows.Count, X).End(xlUp).Row - 1
       
      Z = Application.InputBox(prompt:="Target Column ", Title:="Insert Column Number", Type:=1)
       
       
      
       For i = 2 To LastRow
    If Cells(i, Z).EntireRow.Hidden = False Then
        Cells(i, Z).Value = "*" & Cells(i, X).Value & "*"
    Else
        Cells(i, Z).ClearContents
    End If
Next i

 
End Sub
 

Discussions similaires

Réponses
77
Affichages
6 K
Réponses
14
Affichages
1 K

Statistiques des forums

Discussions
312 501
Messages
2 089 014
Membres
104 005
dernier inscrit
Maxence