Copying and pasting cell values in the cell below it

Waffels

New Member
Joined
Oct 15, 2017
Messages
4
Hello,

I am currently working on making macros to make my life easier and wondering if you nice people can help me as I have 0 knowledge of this macro stuff and am learning. I am trying to make it so cells with certain values get their values pasted in the cell below it. I think I am on the right track. Can anyone help me?

Sub ok()
Dim c As Range
For Each c In Range("J1:J80")
If c.Value Like "*TW747*" Or c.Value Like "*TW691*" Or c.Value Like "*TW2200*" Or c.Value Like "*TW750*" Or c.Value Like "*TW409*" Or c.Value Like "*TW742*" Then
WHAT GOES HERE?
WHAT GOES HERE?
End If
Next c
End Sub
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Hi & welcome to MrExcel.
Not quite sure what you're doing, but if J1 contains, say, TW747, then that value will get copied all the way down to J81. Is that correct?
 
Upvote 0
Hello Guys,

This is what im trying to do

[TABLE="width: 963"]
<colgroup><col span="5"><col><col span="3"><col><col span="2"><col><col></colgroup><tbody>[TR]
[TD]1[/TD]
[TD]301[/TD]
[TD]88[/TD]
[TD]4155[/TD]
[TD] [/TD]
[TD]MRPXX123[/TD]
[TD]000[/TD]
[TD]000[/TD]
[TD] [/TD]
[TD]TW123-50[/TD]
[TD="align: right"]277541[/TD]
[TD] [/TD]
[TD] [/TD]
[TD="align: right"]23.00[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]301[/TD]
[TD]88[/TD]
[TD]4155[/TD]
[TD] [/TD]
[TD]MRPXX220[/TD]
[TD]000[/TD]
[TD]000[/TD]
[TD][/TD]
[TD]TW2200-81[/TD]
[TD="align: right"]277469[/TD]
[TD][/TD]
[TD] [/TD]
[TD="align: right"]18.40[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]301[/TD]
[TD]88[/TD]
[TD]4155[/TD]
[TD] [/TD]
[TD]MRPXX220[/TD]
[TD]000[/TD]
[TD]000[/TD]
[TD] [/TD]
[TD]TW2200-81[/TD]
[TD="align: right"]277519[/TD]
[TD][/TD]
[TD] [/TD]
[TD="align: right"]18.40[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]301[/TD]
[TD]88[/TD]
[TD]4155[/TD]
[TD] [/TD]
[TD]MRPXX221[/TD]
[TD]000[/TD]
[TD]000[/TD]
[TD] [/TD]
[TD]TW221-395[/TD]
[TD="align: right"]277542[/TD]
[TD][/TD]
[TD] [/TD]
[TD="align: right"]59.80[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]301[/TD]
[TD]88[/TD]
[TD]4155[/TD]
[TD] [/TD]
[TD]MRPXX409[/TD]
[TD]000[/TD]
[TD]000[/TD]
[TD] [/TD]
[TD]TW409-74[/TD]
[TD="align: right"]277493[/TD]
[TD][/TD]
[TD] [/TD]
[TD="align: right"]36.80[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]301[/TD]
[TD]88[/TD]
[TD]4155[/TD]
[TD] [/TD]
[TD]MRPXX409[/TD]
[TD]000[/TD]
[TD]000[/TD]
[TD][/TD]
[TD]TW409-74[/TD]
[TD="align: right"]277500[/TD]
[TD][/TD]
[TD] [/TD]
[TD="align: right"]140.76[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]301[/TD]
[TD]88[/TD]
[TD]4155[/TD]
[TD] [/TD]
[TD]MRPXX409[/TD]
[TD]000[/TD]
[TD]000[/TD]
[TD][/TD]
[TD]TW409-74[/TD]
[TD="align: right"]277511[/TD]
[TD][/TD]
[TD] [/TD]
[TD="align: right"]36.80[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
</tbody>[/TABLE]


I want to automate a copy and paste. For example id to be able to repaste the bolded values in the cells directly 1 below. I was thinking of using something like this, but I am unsure what would come afterwards as I am a novice.

Sub try()
Dim c As Range
For Each c In Range("J1:K80")
If c.Value Like "*TW747*" Or c.Value Like "*TW691*" Or c.Value Like "*TW2200*" Or c.Value Like "*TW750*" Or c.Value Like "*TW409*" Or c.Value Like "*TW742*" Then
 
Upvote 0
[TABLE="width: 963"]
<colgroup><col span="5"><col><col span="3"><col><col span="2"><col><col></colgroup><tbody>[TR]
[TD]1[/TD]
[TD]301[/TD]
[TD]88[/TD]
[TD]4155[/TD]
[TD] [/TD]
[TD]MRPXX123[/TD]
[TD]000[/TD]
[TD]000[/TD]
[TD] [/TD]
[TD]TW123-50[/TD]
[TD="align: right"]277541[/TD]
[TD] [/TD]
[TD] [/TD]
[TD="align: right"]23.00[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]301[/TD]
[TD]88[/TD]
[TD]4155[/TD]
[TD] [/TD]
[TD]MRPXX220[/TD]
[TD]000[/TD]
[TD]000[/TD]
[TD][/TD]
[TD]TW2200-81[/TD]
[TD="align: right"]277469[/TD]
[TD][/TD]
[TD] [/TD]
[TD="align: right"]18.40[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]301[/TD]
[TD]88[/TD]
[TD]4155[/TD]
[TD] [/TD]
[TD]MRPXX220[/TD]
[TD]000[/TD]
[TD]000[/TD]
[TD] [/TD]
[TD]TW2200-81[/TD]
[TD="align: right"]277519[/TD]
[TD][/TD]
[TD] [/TD]
[TD="align: right"]18.40[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]301[/TD]
[TD]88[/TD]
[TD]4155[/TD]
[TD] [/TD]
[TD]MRPXX221[/TD]
[TD]000[/TD]
[TD]000[/TD]
[TD] [/TD]
[TD]TW221-395[/TD]
[TD="align: right"]277542[/TD]
[TD][/TD]
[TD] [/TD]
[TD="align: right"]59.80[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]301[/TD]
[TD]88[/TD]
[TD]4155[/TD]
[TD] [/TD]
[TD]MRPXX409[/TD]
[TD]000[/TD]
[TD]000[/TD]
[TD] [/TD]
[TD]TW409-74[/TD]
[TD="align: right"]277493[/TD]
[TD][/TD]
[TD] [/TD]
[TD="align: right"]36.80[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]301[/TD]
[TD]88[/TD]
[TD]4155[/TD]
[TD] [/TD]
[TD]MRPXX409[/TD]
[TD]000[/TD]
[TD]000[/TD]
[TD][/TD]
[TD]TW409-74[/TD]
[TD="align: right"]277500[/TD]
[TD][/TD]
[TD] [/TD]
[TD="align: right"]140.76[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]301[/TD]
[TD]88[/TD]
[TD]4155[/TD]
[TD] [/TD]
[TD]MRPXX409[/TD]
[TD]000[/TD]
[TD]000[/TD]
[TD][/TD]
[TD]TW409-74[/TD]
[TD="align: right"]277511[/TD]
[TD][/TD]
[TD] [/TD]
[TD="align: right"]36.80[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
</tbody>[/TABLE]
Hello everyone,

I want to automate a copy and paste. For example id to be able to repaste the bolded values in the cells directly 1 below. I was thinking of using something like this, but I am unsure what would come afterwards as I am a novice.

Sub try()
Dim c As Range
For Each c In Range("J1:K80")
If c.Value Like "*TW747*" Or c.Value Like "*TW691*" Or c.Value Like "*TW2200*" Or c.Value Like "*TW750*" Or c.Value Like "*TW409*" Or c.Value Like "*TW742*" Then
 
Upvote 0
I'm still not sure I understand.
Are all your rows separated by blank rows?
If so do you want to copy cells J & K down 1 row regardless?
 
Upvote 0
But you have an issue here, because the macro will start copying information from the above cell after your first match for the remaining list. So maybe change your pasting location into a different column.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,325
Members
452,635
Latest member
laura12345

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