Userform Command Button - Match range/copy row

jiveass1960

New Member
Joined
Aug 20, 2019
Messages
19
Hello,

This is my first post. I've tried searching this out without success. Probably because my VB skills are non-existent. Anyway, what I'm trying to accomplish is, I have a userform with a command button on sheet5. When the button is executed, I would like index/match sheet5 column A against sheet 2 column O. They are unique values so there will either be no match, or a single match. When a match is made, I would like to copy the rowdata from b:f of sheet5 and paste it to the matching row on sheet2 q:u. Apologies in advance as I am a novice.

Thank you.
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Hi & welcome to MrExcel
How about
Code:
Sub jiveass1960()
   Dim Cl As Range
   Dim Dic As Object
   
   Set Dic = CreateObject("scripting.dictionary")
   With Sheets("Sheet5")
      For Each Cl In .Range("A2", .Range("A" & Rows.Count).End(xlUp))
         Dic.item(Cl.Value) = Cl.Offset(, 1).Resize(, 5)
      Next Cl
   End With
   With Sheets("Sheet2")
      For Each Cl In .Range("A2", .Range("A" & Rows.Count).End(xlUp))
         Cl.Offset(, 16).Resize(, 5) = Dic.item(Cl.Value)
      Next Cl
   End With
End Sub
 
Upvote 0
Good morning! First off, thank you Fluff for your help. When running this, I do not get any errors, but I cannot determine if anything is actually happening. There are a few quick flashes but that is all. No data is copied from sheet 5 to sheet 2.
 
Upvote 0
Apologies, I didn't read your op properly.
Try
Code:
Sub jiveass1960()
   Dim Cl As Range
   Dim Dic As Object
   
   Set Dic = CreateObject("scripting.dictionary")
   With Sheets("Sheet5")
      For Each Cl In .Range("A2", .Range("A" & Rows.Count).End(xlUp))
         Dic.item(Cl.Value) = Cl.Offset(, 1).Resize(, 5)
      Next Cl
   End With
   With Sheets("Sheet2")
      For Each Cl In .Range("O2", .Range("O" & Rows.Count).End(xlUp))
         Cl.Offset(, 2).Resize(, 5) = Dic.item(Cl.Value)
      Next Cl
   End With
End Sub
 
Upvote 0
This works perfectly. Thank you Fluff!

Apologies, I didn't read your op properly.
Try
Code:
Sub jiveass1960()
   Dim Cl As Range
   Dim Dic As Object
   
   Set Dic = CreateObject("scripting.dictionary")
   With Sheets("Sheet5")
      For Each Cl In .Range("A2", .Range("A" & Rows.Count).End(xlUp))
         Dic.item(Cl.Value) = Cl.Offset(, 1).Resize(, 5)
      Next Cl
   End With
   With Sheets("Sheet2")
      For Each Cl In .Range("O2", .Range("O" & Rows.Count).End(xlUp))
         Cl.Offset(, 2).Resize(, 5) = Dic.item(Cl.Value)
      Next Cl
   End With
End Sub
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,207
Members
448,554
Latest member
Gleisner2

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