Help! : How to copy row into another tab if value in “C4” matches value “PB”

Animalised

New Member
Joined
Apr 24, 2016
Messages
31
I am using VBA for excel and not having success in creating a macro that suits my needs. I'm trying to create a macro that can be run on the Active X Control Button. I'm trying to do this: If Cell "C4" has employee code "PB" then I want to copy that line of text and paste it onto another tab named "Patrick Brenn".
I also want for the macro to compile a list in that separate tab, named "Patrick Brenn" (which is why the Employee code is "PB"), in a way that doesn't delete the previous pasted entry.
When the data has been copied over, I'm looking (with no success currently) to change the "PB" Value to "PB1", then "PB2", and then "PB3" each time information is pasted into.
Does anyone know how to do this as I am completely new to this and am very stuck! Thank-you for any help you are able to provide!
(p.s. I can show you my macro but its a mess and doesn't work; ive tried to mash a few macros together and adjust them to my particular needs with, again, no success).
Thank you in advance if you're able to help in this matter!
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Code:
Sub test()If Range("C4") = "PB" Then Range("C4").EntireRow.Copy Sheets("Patrick Brenn").Range("A" & Rows.Count).End(xlUp).Offset(1)
End Sub

Kind regards
Leo
 
Upvote 0
Thank you Leo for the help, its much appreciated and has helped me to understand this better!

Good night!
 
Upvote 0

Forum statistics

Threads
1,216,742
Messages
6,132,453
Members
449,729
Latest member
davelevnt

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