A few words of thanks would be greatly appreciated. Add comment
4333 users have said thank you to us this month
Sub MoveData() Dim lRow As Integer lRow = Range("A" & Rows.Count).End(xlUp).Row Sheets("raw").Activate For Each cell In Range("F2:F" & lRow) cell.EntireRow.Copy Sheets(cell.Value).Activate Range("B" & Rows.Count).End(xlUp).Offset(1, -1).PasteSpecial Next cell Application.CutCopyMode = False End Sub
Sub MoveData() Dim lRow As Integer lRow = Range("A" & Rows.Count).End(xlUp).Row Sheets("raw").Activate For Each cell In Range("F2:F" & lRow) If Not SheetExists(cell.Value) Then Sheets.Add ActiveSheet.Name = cell.Value Sheets("raw").Range("A1:F1").Copy Sheets(cell.Value).Range("A1").PasteSpecial Paste:=xlPasteAll Sheets(cell.Value).Range("A1").PasteSpecial Paste:=xlPasteColumnWidths End If cell.EntireRow.Copy Sheets(cell.Value).Activate Range("B" & Rows.Count).End(xlUp).Offset(1, -1).PasteSpecial Next cell Application.CutCopyMode = False End Sub Function SheetExists(SheetName As String) As Boolean SheetExists = False On Error GoTo NoSuchSheet If Len(Sheets(SheetName).Name) > 0 Then SheetExists = True Exit Function End If NoSuchSheet: End Function
but this is showing error called "invalid and unqualified" and also please let me know where we can set the condition?