Thursday, October 24, 2019

microsoft excel - How do I implement the VBA module to copy filtered data

I need to implement a VBA Macro that copies data from one excel worksheet and puts certain column into another one.


Sub sbCopyRangeToAnotherSheet()
'Method 1
Sheets("Sheet1").Range("A1:B10").Copy Destination:=Sheets("Sheet2").Range("E1")
'Method 2
'Copy the data
Sheets("Sheet1").Range("A1:B10").Copy
'Activate the destination worksheet
Sheets("Sheet2").Activate
'Select the target range
Range("E1").Select
'Paste in the target destination
ActiveSheet.Paste
Application.CutCopyMode = False
End Sub

This wont work for new sheets named for example Sheet 3 neither will it run effectively for filtered data. I need a code that can copy the filtered data and paste certain column into another worksheet.

No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...