PDA

View Full Version : excel vba



ramola0911
09-10-2018, 10:24 AM
I want to extract data from one worksheet to another worksheet with criteria (i) Center(Alphabet) and (ii) between two dates in excel.

I have use following code for this and i use input box for variable criteria(i) center.


Sub mcopy()
Call DeleteRowsBelow
a = Worksheets("CRM").Cells(Rows.Count, 1).End(xlUp).Row

Dim myModule As String
myModule = Application.InputBox("Enter a Module")

For i = 2 To a
If Worksheets("CRM").Cells(i, 4).Value = myModule Then

Worksheets("CRM").Rows(i).Copy
Worksheets("MODCRM").Activate
b = Worksheets("MODCRM").Cells(Rows.Count, 1).End(xlUp).Row

Worksheets("MODCRM").Cells(b + 1, 1).Select
ActiveSheet.Paste
Worksheets("CRM").Activate
End If
Next

Application.CutCopyMode = False
'ThisWorkbook.Worksheets("CRM").Cells(1, 1).Select

End Sub

Sub DeleteRowsBelow()
Worksheets("MODCRM").Rows(3 & ":" & Worksheets("MODCRM").Rows.Count).Delete
End Sub

In this code, i want to use center at particular center on CRM sheet (i.e. on $d$1 cell) and dates are at $h$1 and $g$1.

Can any one help for solving this.