Hi All,
I am new to Excel Macro and to this forum. I am trying to write a macro to copy a range multiple times. Please correct me if I am wrong.
Sub Macro1()
Dim x As String
Dim x1 As String
Dim x2 As String
Dim p, q As Integer
Range("A1").Activate
p = 1
q = 1
For i = 1 To 2 Step 1
x2 = Trim(Cells(i, 1).Value)
x = Trim(Cells(i, 2).Value)
p = 1
For j = 1 To c Step 1
q = InStr(p, x)
x1 = Mid(x, p, q - p)
ActiveCell.Value = x2
ActiveCell.Offset(0, 1).Value = x1
ActiveCell.Offset(1, 0).Activate
p = q + 1
Next j
Next i
End Sub
Please see the below-attached image example,
Input
Output
Thank you in advance.
I am new to Excel Macro and to this forum. I am trying to write a macro to copy a range multiple times. Please correct me if I am wrong.
Sub Macro1()
Dim x As String
Dim x1 As String
Dim x2 As String
Dim p, q As Integer
Range("A1").Activate
p = 1
q = 1
For i = 1 To 2 Step 1
x2 = Trim(Cells(i, 1).Value)
x = Trim(Cells(i, 2).Value)
p = 1
For j = 1 To c Step 1
q = InStr(p, x)
x1 = Mid(x, p, q - p)
ActiveCell.Value = x2
ActiveCell.Offset(0, 1).Value = x1
ActiveCell.Offset(1, 0).Activate
p = q + 1
Next j
Next i
End Sub
Please see the below-attached image example,
Input
Output
Thank you in advance.