vba script to lookup and place

edward233

Board Regular
Joined
Jul 4, 2002
Messages
65
Hi
Im trying to write a vba script to

Lookup data in col g on page 2 once it finds data lets say in g4 it copys data in b4
and places in sheet1 b2 then it continues down g in shee2 finds data in g15 copys data in b15 places it on sheet1 b3 and so on till it gets to g40 on sheet2.

any help appritated.
thanks

ed
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Hi
correction

Lookup data in col g on sheet2 once it finds data lets say in g4 it copys data in b4
and places in sheet1 b2 then it continues down g in shee2 finds data in g15 copys data in b15 places it on sheet1 b3 and so on till it gets to g40 on sheet2.

any help appritated.
thanks

ed
 
Upvote 0
Try

Code:
Sub test()
Dim i As Integer, j As Integer
j = 1
With Sheets("Sheet2")
    For i = 1 To 40
        If .Range("G" & i) <> "" Then
            j = j + 1
            Sheets("Sheet1").Range("B" & j).Value = .Range("B" & i).Value
        End If
    Next i
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,217,676
Messages
6,137,934
Members
450,099
Latest member
Pushbutton

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top