Transfer data from one worksheet to another

JayB0730

Board Regular
Joined
Oct 22, 2014
Messages
74
Office Version
  1. 365
Platform
  1. Windows
Hello,

I have the following vba code that works to a degree; however, I want to make a few changes.

1. Instead of the logic looking for any rows with data in column 37, I want it to find specific values (e.g. "Apple") instead.
2. Paste the information into the new sheet without any formatting.

Code:
Sub SelectDestruct()   Dim Ar As Areas
   Dim Rng As Range
   
   Sheets("Destination_Sheet").UsedRange.Offset(1).Clear
   On Error Resume Next
   Set Ar = Sheets("Origin_Sheet").Columns(37).SpecialCells(xlCellTypeConstants, xlTextValues).Areas
   On Error GoTo 0
   If Ar Is Nothing Then
      MsgBox "Nothing to do!"
      Exit Sub
   End If
   For Each Rng In Ar
      Rng.Offset(, -35).Resize(, 12).Copy Sheets("Destination_Sheet").Range("A" & Rows.Count).End(xlUp).Offset(1)
   Next Rng
Call Confirmation
End Sub

TIA!

Jay
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Untested, but try
Code:
Sub SelectDestruct()
   
   Sheets("Destination_Sheet").UsedRange.Offset(1).Clear
   With ActiveSheet
      If .AutoFilterMode Then .AutoFilterMode = False
      .Range("A1").UsedRange.AutoFilter 37, "Apple"
      .AutoFilter.Range.Offset(1).Copy
      Sheets("Destination_Sheet").Range("A" & Rows.Count).End(xlUp).Offset (1)
      .AutoFilterMode = False
   End With
Call Confirmation
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,811
Messages
6,181,081
Members
453,021
Latest member
Justyna P

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