whitoulias
Board Regular
- Joined
- Jun 22, 2012
- Messages
- 153
Good day to all
With this code i search in Sheets("data") for -1, copy that entire row to Sheets("Result"), delete the row and sort the sheets("data").
Can anyone tell me if i can add an extra search?
I would like after searching for -1 to perform the same actions for "9". Is that possible?
Since this macro is activated by a command button, can i have two macros in the same button (i'm thinking dublicating the code.
Thank you
With this code i search in Sheets("data") for -1, copy that entire row to Sheets("Result"), delete the row and sort the sheets("data").
Code:
Sub Transfer()
Dim c As Long
Dim wsD As Worksheet: Set wsD = Worksheets("Data") 'Data Worksheet.
Dim wsR As Worksheet: Set wsR = Worksheets("Results") 'Results Worksheet
Range("A2").Select
ActiveCell.FormulaR1C1 = "=COUNTBLANK(RC[1]:RC[17])-1"
Range("A2").Copy Range("A2", Cells(Rows.Count, "B").End(xlUp).Offset(0, -1))
For c = 2 To 3002 'Loop through 3000 records.
With wsD.Range("A" & c)
If .Value = -1 Then 'Test for -1.
wsD.Range("B" & c & ":S" & c & "").Copy
wsR.Activate
wsR.Range("A" & wsR.Range("A" & Rows.Count).End(xlUp).Row + 1).Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End If
End With
Next c
For c = 2 To 3002 'Loop through 3000 records.
With wsD.Range("A" & c)
If .Value = -1 Then 'Test for -1.
wsD.Range("B" & c & ":S" & c & "").ClearContents
End If
End With
Next c
wsD.Activate
Range("A1:S3002").Select
Selection.Sort Key1:=Range("H2"), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End Sub
Can anyone tell me if i can add an extra search?
I would like after searching for -1 to perform the same actions for "9". Is that possible?
Since this macro is activated by a command button, can i have two macros in the same button (i'm thinking dublicating the code.
Thank you