Find text then Copy Adjacent Cell and Paste into two seperate cells

articfox

New Member
Joined
Nov 6, 2018
Messages
2
Hello, just hoping to get some help with this. I’ve two words that have different values associated with them, I just want to findthe words and copy the values from the adjacent cells into separate cells for example Cell R43, R45, R47 etc for the value associated with Wait and a separate cell S42, S44, S46 etc for the value associated with resume, see below. What I’m finding is that it’ll copy the values multipletimes into column R and S and repeat the last value over and over again when I just want it to be sequential.


Thanks for any help. Cheers



Sub Search()

' Defines variables
Dim Cell, cRange As Range

' Sets the range to check
Set cRange =Range("E3:E303")
' For each cell in range
For Each CellIn cRange
' If cell value is "Wait" then...
IfCell.Value = "Wait" Then
' The value in column E on the same row equals the samevalue as 1 cells to the right of the beings cell
Range("R34:R0" & (Cell.Row)).Value = Cell.Offset(0,6).Value
End If
' Check next cell in range
Next Cell

' Sets the range to check
Set cRange =Range("E3:E303")
' For each cell in range
For Each CellIn cRange
' If cell value is "Resume" then...
If Cell.Value = "Resume" Then
' The value in column E on the same row equals the samevalue as 1 cells to the right of the beings cell
Range("S34:S0" & (Cell.Row)).Value = Cell.Offset(0,6).Value
End If
' Check next cell in range

Next Cell

End Sub


Thanks again
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Your code is a little confusing. It searches a range in column E for the words "Wait" and "Resume". Then it assigns the value in column K (Cell.Offset(0,6).Value) to column R for "Wait" or column S for "Resume". In your post you said
find the words and copy the values from the adjacent cells
The "adjacent cells" would be in column F not column K. Could you please clarify in detail.
 
Upvote 0
Hi there. It looks like you are pasting into row 34 onwards each time - try replacing
Code:
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Range("R34:R0" & (Cell.Row)).Value = Cell.Offset(0,6).Value[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][/FONT]
with
Code:
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Range("R" & (Cell.Row)).Value = Cell.Offset(0,6).Value[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][/FONT]
and
Code:
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Range("S34:S0" & (Cell.Row)).Value = Cell.Offset(0,6).Value[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][/FONT]
with
Code:
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Range("S" & (Cell.Row)).Value = Cell.Offset(0,6).Value[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][/FONT]
 
Upvote 0
Hi there. It looks like you are pasting into row 34 onwards each time - try replacing
Code:
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Range("R34:R0" & (Cell.Row)).Value = Cell.Offset(0,6).Value[/COLOR][/SIZE][/FONT]
with
Code:
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Range("R" & (Cell.Row)).Value = Cell.Offset(0,6).Value[/COLOR][/SIZE][/FONT]
and
Code:
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Range("S34:S0" & (Cell.Row)).Value = Cell.Offset(0,6).Value[/COLOR][/SIZE][/FONT]
with
Code:
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Range("S" & (Cell.Row)).Value = Cell.Offset(0,6).Value[/COLOR][/SIZE][/FONT]


Thanks it worked a charm. Cheers
 
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,331
Members
449,077
Latest member
jmsotelo

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