Copy & paste range once specific value in cell in reached

thechad

Board Regular
Joined
Apr 28, 2014
Messages
117
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Greetings all,

I have a range from G2:G2000 that contains mixed values in the cells. There will be a point where the cells begin saying "No Match" and will continue to the end of the range doing so. I need a macro that will copy from G2 all the way to the last value just above the first cell that says "No Match". Once that is copied, I would like to take those values and paste them in cell A2 downwards but as "Values" only.

Can this be done? Assistance would be appreciated.

Thanks so much!
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Try this:
VBA Code:
Sub NoMatch()
Dim i as Integer
'start with row 2
i = 2

'loop through each cell in G until you hit "No Match" or G2000
Do While i < 2001 And Not Cells(i, 7).Value = "No Match"
    'copy G to I in the same row
    Cells(i, 1) = Cells(i, 7)
    'increment the counter
    i = i + 1
'next row
Loop

End Sub
 
Upvote 0
Try this:
VBA Code:
Sub NoMatch()
Dim i as Integer
'start with row 2
i = 2

'loop through each cell in G until you hit "No Match" or G2000
Do While i < 2001 And Not Cells(i, 7).Value = "No Match"
    'copy G to I in the same row
    Cells(i, 1) = Cells(i, 7)
    'increment the counter
    i = i + 1
'next row
Loop

End Sub
Bill...this works awesome!!! Thank you so much for you help!

C
 
Upvote 0

Forum statistics

Threads
1,214,795
Messages
6,121,624
Members
449,041
Latest member
Postman24

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