PDA

View Full Version : Macro to repeat merge, Filter, copy & paste to other sheet.



mirat1687
09-09-2013, 05:06 AM
Hello,

I am new to Macro and VBA. This is important, hope some one can sort this at priority.

I have a file with columns running into 100s. I need to merge every 2 columns to set the header right and then filer "Remove blanks" , copy the result and paste into new sheet.

I need to repeat this to every next merged cell of header. For example, cell E1 merge with F1, filter the cell"E1:F1", with "Remove blanks, copy from A1 till F1 (till last cell of row) and paste to new sheet. Now repeat is for G1 merge with H1 and so on.

Also, paste should happen in the same sheet one row after another.

My current Macro is here :-

Sub Macro1()
'
' Macro1 Macro
'


'
Range("C1:D1").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
Selection.AutoFilter
ActiveSheet.Range("$A$1:$EA$83").AutoFilter Field:=3, Criteria1:="<>"
Range("B2:D10").Select
Selection.Copy
End Sub