If x = x then copy

Damianjay

New Member
Joined
Jun 3, 2011
Messages
5
Hello,
I'm trying to right a macro where IF user ID (column K in master sheet) = User ID (column B in Info Sheet) then Copy Cells C,D,E (From Infor Sheet) to Cells (N, O, P in Master Sheet)

Been pulling whats left of my hair out trying to do this

Please help
Thanks
Damian
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Code:
Sub PullingWhatsLeftOfMyHairOut()
    If Sheets("Master").Range("K1") = Sheets("Info").Range("B1") Then
        Sheets("Master").Range("C1:E1").Copy Sheets("Info").Range("N1")
    End If
End Sub
 
Upvote 0
Something like:
Code:
Sub UnicornsDontExit ()
 
Dim wm as Worksheet, wi as worksheet
Dim i as Long
 
Set wm = Sheets("Master")
Set wi = Sheets("Info")
 
With Application
    .ScreenUpdating = False
    .Calculation = xlCalculationManual
End With
 
With wm
  For i = 1 to .Range("K" & Rows.Count).End(xlUp).Row
     If .Range("K" & i) = wi.Range("B" & i) Then .Range("N" & i & ":P" & i) = wi.Range("C" & i & ":E" & i)
  Next i
End With
 
With Application
    .ScreenUpdating = True
    .Calculation = xlCalculationAutomatic
End With
 
End Sub
 
Upvote 0
Maybe like this

Code:
Sub test()
Dim LR As Long, i As Long
With Sheets("Info")
    LR = .Range("B" & Rows.Count).End(xlUp).Row
    For i = 1 To LR
        If .Range("B" & i).Value = Sheets("Master").Range("K" & i).Value Then
            .Range("C" & i).Resize(, 3).Copy Destination:=Sheets("Master").Range("N" & i)
        End If
    Next i
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,291
Members
452,902
Latest member
Knuddeluff

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