How to install your new code
- Copy the Excel VBA code
- Select the workbook in which you want to store the Excel VBA code
- Press Alt+F11 to open the Visual Basic Editor
- Choose Insert > Module
- Edit > Paste the macro into the module that appeared
- Close the VBEditor
- Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)
Sub ManipulateData()
Dim rMyRng_1 As Range, rMyRng_2 As Range, rResult As Range, r As Range, lRws As Long
Dim rPosition As Range
Set rPosition = ActiveCell
Set rMyRng_1 = Application.InputBox("Select The First Range", "Range 1 Req.", , , , , , 8)
Set rMyRng_2 = Application.InputBox("Select The Second Range", "Range 2 Req.", , , , , , 8)
Set rResult = Application.InputBox("Select The Result Cell", "Result Cell Req.", , , , , , 8)
Set rResult = rResult.Cells(1)
Application.ScreenUpdating = False
With rMyRng_2
.Copy
lRws = .Rows.Count
End With
For Each r In rMyRng_1.Cells
With rResult
.PasteSpecial xlPasteValues
.Offset(, 1).Resize(rMyRng_2.Rows.Count).Value = r.Value
Set rResult = .Offset(rMyRng_2.Rows.Count)
End With
Next r
rPosition.Select
Application.ScreenUpdating = True
End Sub
To run the Excel VBA code:- Press Alt-F8 to open the macro list
- Select a macro in the list
- Click the Run button
Bookmarks