Hello All,
I am using below code to move the data to different sheets. The problem is my data is not same always. Code is returning error if the data is not existing. Please suggest how to modify the code to move forward to next even some of the data not availble.
Thanks in advance
Sub CopyRows_new()
Dim lr As Long
'Application.ScreenUpdating = False
Sheets.Add.Name = "FA-3A Port 0"
Sheets.Add.Name = "FA-3A Port 1"
Sheets.Add.Name = "FA-3B Port 0"
Sheets.Add.Name = "FA-3B Port 1"
Sheets.Add.Name = "FA-3C Port 0"
Sheets.Add.Name = "FA-3C Port 1"
Rows(1).EntireRow.Insert
lr = Range("A" & Rows.Count).End(xlUp).Row
With Range("A1:A" & lr)
.AutoFilter Field:=1, Criteria1:="FA-3A Port 0"
.Resize(.Rows.Count - 1, 8).Offset(1).Copy _
Destination:=Sheets("FA-3A Port 0").Range("A1")
.AutoFilter
.AutoFilter Field:=1, Criteria1:="FA-3A Port 1"
.Resize(.Rows.Count - 1, 8).Offset(1).Copy _
Destination:=Sheets("FA-3A Port 1").Range("A1")
.AutoFilter
.AutoFilter Field:=1, Criteria1:="FA-3B Port 0"
.Resize(.Rows.Count - 1, 8).Offset(1).Copy _
Destination:=Sheets("FA-3B Port 0").Range("A1")
.AutoFilter
.AutoFilter Field:=1, Criteria1:="FA-3B Port 1"
.Resize(.Rows.Count - 1, 8).Offset(1).Copy _
Destination:=Sheets("FA-3B Port 1").Range("A1")
.AutoFilter
.AutoFilter Field:=1, Criteria1:="FA-3C Port 0"
.Resize(.Rows.Count - 1, 8).Offset(1).Copy _
Destination:=Sheets("FA-3C Port 0").Range("A1")
.AutoFilter
.AutoFilter Field:=1, Criteria1:="FA-3C Port 1"
.Resize(.Rows.Count - 1, 8).Offset(1).Copy _
Destination:=Sheets("FA-3C Port 1").Range("A1")
.AutoFilter
End With
Rows(1).EntireRow.Delete
Sheets("masking").Select
Application.ScreenUpdating = True
End Sub
I am using below code to move the data to different sheets. The problem is my data is not same always. Code is returning error if the data is not existing. Please suggest how to modify the code to move forward to next even some of the data not availble.
Thanks in advance
Sub CopyRows_new()
Dim lr As Long
'Application.ScreenUpdating = False
Sheets.Add.Name = "FA-3A Port 0"
Sheets.Add.Name = "FA-3A Port 1"
Sheets.Add.Name = "FA-3B Port 0"
Sheets.Add.Name = "FA-3B Port 1"
Sheets.Add.Name = "FA-3C Port 0"
Sheets.Add.Name = "FA-3C Port 1"
Rows(1).EntireRow.Insert
lr = Range("A" & Rows.Count).End(xlUp).Row
With Range("A1:A" & lr)
.AutoFilter Field:=1, Criteria1:="FA-3A Port 0"
.Resize(.Rows.Count - 1, 8).Offset(1).Copy _
Destination:=Sheets("FA-3A Port 0").Range("A1")
.AutoFilter
.AutoFilter Field:=1, Criteria1:="FA-3A Port 1"
.Resize(.Rows.Count - 1, 8).Offset(1).Copy _
Destination:=Sheets("FA-3A Port 1").Range("A1")
.AutoFilter
.AutoFilter Field:=1, Criteria1:="FA-3B Port 0"
.Resize(.Rows.Count - 1, 8).Offset(1).Copy _
Destination:=Sheets("FA-3B Port 0").Range("A1")
.AutoFilter
.AutoFilter Field:=1, Criteria1:="FA-3B Port 1"
.Resize(.Rows.Count - 1, 8).Offset(1).Copy _
Destination:=Sheets("FA-3B Port 1").Range("A1")
.AutoFilter
.AutoFilter Field:=1, Criteria1:="FA-3C Port 0"
.Resize(.Rows.Count - 1, 8).Offset(1).Copy _
Destination:=Sheets("FA-3C Port 0").Range("A1")
.AutoFilter
.AutoFilter Field:=1, Criteria1:="FA-3C Port 1"
.Resize(.Rows.Count - 1, 8).Offset(1).Copy _
Destination:=Sheets("FA-3C Port 1").Range("A1")
.AutoFilter
End With
Rows(1).EntireRow.Delete
Sheets("masking").Select
Application.ScreenUpdating = True
End Sub