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

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

edward233

Board Regular
Joined
Jul 4, 2002
Messages
65
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
 

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,851
Messages
5,833,965
Members
430,249
Latest member
Muka

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
Top