james888sa
New Member
- Joined
- Aug 4, 2021
- Messages
- 2
- Office Version
- 2016
- Platform
- 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.
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