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
 

Some videos you may like

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

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
 

Watch MrExcel Video

Forum statistics

Threads
1,123,396
Messages
5,601,420
Members
414,449
Latest member
Pashtun

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