Code To Look For Number On Sheet 1 And Put Another Number Directly Below

Dazzawm

Well-known Member
Joined
Jan 24, 2011
Messages
3,748
Office Version
  1. 365
Platform
  1. Windows
I have sheet 2 with a list of numbers in column A. I need a code please that will look for these numbers on sheet 1 in column AD and put the number that is next to it in column B on sheet 2 in the cell directly below in column Ad on sheet 1. Thanks.


Excel 2010
AB
1
2TestTest1
3DataData1
Sheet2


Sheet 1 Before


Excel 2010
AD
2Test
3NYA
4NYA
5Test
6NLA
7Data
8NYA
9NYA
10NYA
11NYA
12Data
Sheet1


Sheet 1 After. I have highlighted the cells where the data has been added.


Excel 2010
AD
2Test
3Test1
4NYA
5Test
6Test1
7Data
8Data1
9NYA
10NYA
11NYA
12Data
13Data1
Sheet1


Thanks.
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Please let me know if you need any clarification or more examples.
 
Upvote 0
Hi Mick, could you let me know either way if you can help with this please, as I need it for work and will have to think of something else if you can't. Thanks.
 
Upvote 0
Try this:-
Code:
[COLOR=Navy]Sub[/COLOR] MG13Oct00
[COLOR=Navy]Dim[/COLOR] Rng1 [COLOR=Navy]As[/COLOR] Range, Dn [COLOR=Navy]As[/COLOR] Range, Rng2 [COLOR=Navy]As[/COLOR] Range
[COLOR=Navy]With[/COLOR] Sheets("Sheet2")
    [COLOR=Navy]Set[/COLOR] Rng2 = .Range(.Range("A1"), .Range("A" & Rows.Count).End(xlUp))
[COLOR=Navy]End[/COLOR] With
[COLOR=Navy]With[/COLOR] Sheets("Sheet1")
    [COLOR=Navy]Set[/COLOR] Rng1 = .Range(.Range("AD1"), .Range("AD" & Rows.Count).End(xlUp))
[COLOR=Navy]End[/COLOR] With
[COLOR=Navy]With[/COLOR] CreateObject("scripting.dictionary")
.CompareMode = vbTextCompare
[COLOR=Navy]For[/COLOR] [COLOR=Navy]Each[/COLOR] Dn [COLOR=Navy]In[/COLOR] Rng2
   [COLOR=Navy]Set[/COLOR] .Item(Dn.Value) = Dn
[COLOR=Navy]Next[/COLOR]
[COLOR=Navy]For[/COLOR] [COLOR=Navy]Each[/COLOR] Dn [COLOR=Navy]In[/COLOR] Rng1
    [COLOR=Navy]If[/COLOR] .Exists(Dn.Value) [COLOR=Navy]Then[/COLOR]
        Dn.Offset(1).Value = .Item(Dn.Value).Offset(, 1).Value
        Dn.Offset(1, 1).Value = .Item(Dn.Value).Offset(, 2).Value
    [COLOR=Navy]End[/COLOR] If
[COLOR=Navy]Next[/COLOR] Dn
[COLOR=Navy]End[/COLOR] [COLOR=Navy]With[/COLOR]
[COLOR=Navy]End[/COLOR] [COLOR=Navy]Sub[/COLOR]
Regards Mick

Hi Mick could you help with this code you did for me please. I need it amended slightly so that it only enters the data directly below if NLA, NYA or N/A are in the cell please. Please ignore everything from #10 to this post. Thanks.
 
Upvote 0
Also Mick which would be a great help, any cells that couldn't be changed because they had something other than NYA/NLA or NA, then maybe a summary with a list of these on sheet3?
 
Upvote 0
Can Mick or anyone else help with this please. Posts 1, 14 & 15 sum up what I need. Thanks.
 
Upvote 0
I guess I'll have to think of something else on this one!
 
Upvote 0
Do you still need help?
I’m going offline now and will return Monday evening…
 
Last edited:
Upvote 0
Yes I do please, thanks worf. Like I said before #1, #14 & #15 should explain enough what I need thanks.
 
Upvote 0

Forum statistics

Threads
1,215,506
Messages
6,125,189
Members
449,213
Latest member
Kirbito

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