Macro: Find Value and paste data

woodm872

New Member
Joined
Sep 22, 2017
Messages
1
Question...
I am trying to write a macro that takes the Value in B1, finds B1 in row 5 and pulls in the coresponding data in E1:F3. I would just put in an index match match but the data prior to the current week has to be able to stay without getting deleted. Any help is greatly appreciated.



[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]week[/TD]
[TD]34[/TD]
[TD][/TD]
[TD]data[/TD]
[TD]abc[/TD]
[TD]12[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]def[/TD]
[TD]16[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]ghi[/TD]
[TD]20[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]weeks[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD][/TD]
[TD]31[/TD]
[TD]32[/TD]
[TD]33[/TD]
[TD]34[/TD]
[TD]35[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]abc[/TD]
[TD]2[/TD]
[TD]12[/TD]
[TD]8[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]def[/TD]
[TD]16[/TD]
[TD]14[/TD]
[TD]6[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]ghi[/TD]
[TD]8[/TD]
[TD]6[/TD]
[TD]10[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
woodm872,

Welcome to the Board.

You might consider the following...

Code:
Sub GetData()
Dim Col As Long
On Error Resume Next
Col = Rows(5).Find(What:=Range("B1").Value, After:=Cells(5, 1), LookIn:=xlFormulas, _
    LookAt:=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious, MatchCase:=False).Column
On Error GoTo 0
If Col > 0 Then
    Range("E1:E3").Value = Range("A6:A8").Value
    Range("F1:F3").Value = Range(Cells(6, Col), Cells(8, Col)).Value
End If
End Sub

Cheers,

tonyyy
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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