VBA row paste

james888sa

New Member
Joined
Aug 4, 2021
Messages
2
Office Version
  1. 2016
Platform
  1. Windows
Hi guys i need some help on VBA.

I have range of numbers in Sheet 1 from cells A6:O29.

Next i have specific numbers selected in Sheet 3 in Column "B"

I want to loop throw each value in Sheet 3 Column "B" and find that specific value in Sheet 1 range "A6:O29"

Next it should paste Entire Row from Sheet 1 starting From Column ("Q:CF") in Sheet 3 Starting from Column C onwards

I have coded it but its not working.


VBA Code:
Private Sub CommandButton1_Click()


Dim main As Worksheet
Dim outcome As Worksheet

'main sheet contains Range to search number in
Set main = ThisWorkbook.Sheets("Sheet1")

'outcome sheet has specific values in Column B

Set outcome = ThisWorkbook.Sheets("Sheet3")


'column B values are considrered as doubles
Dim valuesfind As Double


'range where values are to be found 
Dim myrange As Range

Set myrange = Worksheets("Sheet1").Range("A6:O29")


'no of times to loop code based on values in outcomesheet
locations = Worksheets("Sheet3").Cells(Rows.Count, 2).End(xlUp).Row


For i = 6 To locations
    degrees = outcome.Range("B" & i).Value
    
    For b = 6 To Worksheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row
        
        If main.Range("A6:O29" & b).Value = degrees Then
            
            outecome.Range("C:BR" & i).Value = main.Range("Q:CF" & b).Value
            
            Exit For
            
        
        End If
        
    
    Next b

Next i


End Sub
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
This is range where i need to find values. For assistance i kept values generic
1628080178911.png



Values that i would like to search and paste Complete row when value is matched

1628080256081.png
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

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