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 FillData()
Dim rFill As Range, lRw As Long, r As Range, rSource As Range, rFound As Range
Application.ScreenUpdating = False
With Sheets("Plant Data Entry Form")
Set rSource = Range("A4:H28")
lRw = .Cells(Rows.Count, "A").End(xlUp).Row
Set rFill = .Range("A41:A" & lRw)
End With
For Each r In rFill.Cells
Set rFound = rSource.Find(r.Value)
If Not rFound Is Nothing Then
r.Offset(, 1).Value = rFound.Offset(, 1).Value
End If
Next r
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