When cell in column contains value, select cell on the right, copy and paste in cell on right again

RoseMurphy

New Member
Joined
Aug 13, 2021
Messages
2
Office Version
  1. 2019
Platform
  1. Windows
Hi there, I'm having trouble figuring this one out, I'd like to include this code in a macro that sorts some information out for me, but for the life of me can't find a code that will just select a column on the left/right without putting the exact cell name, which is not what I want.

Here's basically what I'm trying to do:

If Cell range KO contains the word "How" then copy cell to the right of that cell (KP) and paste to column KQ in the same row.
The excel sheet I will have will have hundreds of varying text, so it needs to just select the column on the right and then paste the text to the next cell on the right, I can't code it to know the cell it will go into which is where I'm lost.

I've added a photo to make this more clear, as I'm not sure if I've explained this very well, most appreciated in advance anyone that can help me out!

(I did post this to another Excel forum, but it seems everyone received a response to their thread but me & I really need help with this, so hopefully this place is more friendly! Thank you in advance)

Posted here When cell in column contains value, then copy cell on right and paste in another column
 

Attachments

  • exceleeeeeeeeeee.PNG
    exceleeeeeeeeeee.PNG
    15.1 KB · Views: 22
  • excel2.PNG
    excel2.PNG
    12.7 KB · Views: 21
Last edited by a moderator:

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
How about
VBA Code:
Sub RoseMurphy()
   With Range("KO2", Range("KO" & Rows.Count).End(xlUp))
      .Offset(, 2).Value = Evaluate(Replace("If(isnumber(search(""how""," & .Address & "))," & .Offset(, 1).Address & ",If(@="""","""",@))", "@", .Offset(, 2).Address))
   End With
End Sub
 
Upvote 0
How about
VBA Code:
Sub RoseMurphy()
   With Range("KO2", Range("KO" & Rows.Count).End(xlUp))
      .Offset(, 2).Value = Evaluate(Replace("If(isnumber(search(""how""," & .Address & "))," & .Offset(, 1).Address & ",If(@="""","""",@))", "@", .Offset(, 2).Address))
   End With
End Sub
Unfortunately this one didn't work for me as it takes data from my other cells and replaces them all with the number 1, I've attached some photos to show what's happening

Photo 11 shows the document before I use your code
Photo 12 shows what happens after I use your code
Photo 13 is the result I'm trying to get
 

Attachments

  • 11.PNG
    11.PNG
    7.9 KB · Views: 19
  • 12.PNG
    12.PNG
    8.3 KB · Views: 20
  • 13.PNG
    13.PNG
    9.5 KB · Views: 18
Upvote 0
Can you post some sample data.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,244
Members
452,622
Latest member
Laura_PinksBTHFT

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