VBA to find value

johngio

Board Regular
Joined
Jan 28, 2005
Messages
174
Hi all,

I'm currently trying to write a macro that will search a range (D17:D40) and when it finds a value the same as cell C4, it will cut and paste the values from cells G15 to P15 to the G to P columns of the corresponding row.

The numbers in D17-D40 are (and always will be):

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
1
2
3
4
5

So, if the value in C4 is 3, then I want to copy the values from G15:P15 to the G38:P38

Any ideas?


I know manually I could do a match to get the row number , etc ,etc, but I'm trying to combine several smaller macros so I only have to click a single button . . .

Cheers

John
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
John

How about

Code:
Sub ddd()
  Set findit = Range("D17:D40").Find(what:=Range("C4").Value, lookat:=xlWhole)
  findit.Offset(0, 1).Resize(1, 10).Value = Range("G15:P15").Value
End Sub


Tony
 
Upvote 0
Awesome!

Works a treat. I had created a loop function but couldn't figure out the offest part :P Your way is a lot more efficient.

Thanks
 
Upvote 0

Forum statistics

Threads
1,215,063
Messages
6,122,930
Members
449,094
Latest member
teemeren

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