Copy and paste a range in a row that contain certain text in specific cell

Musto85

New Member
Joined
Mar 6, 2022
Messages
21
Platform
  1. Windows
Hi everyone,

I'm new to vba coding and I was wondering if you could help with this...
I have this code below that copies and pastes a range to a closed spreadsheet in a table.
At the moment it copies the whole range "F24:M27" which resides in the sheet "Setup", however I would like the code to copy only the row where the text "Check" is present in column "I" and therefore copy only that row and disregard the others (copy always from column F to M and not the entire row).

Dim destSht As Worksheet

Workbooks.Open ("H:\Project\Checklist tracker 2.xlsb") '<- at opening a workbook it becomes the active one
Set destSht = ActiveWorkbook.Worksheets("Checklist Table") '<-- set the destination worksheet in the activeworkbook
With ThisWorkbook.Worksheets("Setup") '<--refer to your source worksheet in the workbook this macro resides in

With .Range(.Range("F24:M27"), .Range("F24:M27").End(xlDown)) '<--| refer to the range whose values are to be copied
Application.GoTo Reference:="R10000C4"
destSht.Cells(destSht.Rows.count, 4).End(xlUp).Offset(1).Resize(.Rows.count, .Columns.count).Value = .Value '<--| copy values in a equally sized range in destination worksheet

End With
End With

destSht.Parent.Close True '<-- close the destination workbook


Thank you in advance!!
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Forum statistics

Threads
1,214,920
Messages
6,122,279
Members
449,075
Latest member
staticfluids

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