L
Len
Hi
I am copying a dynamic range of cells from 12 different worksheets
under workbook A.
I need to select an adjacent range that starts with "OP" ( always at
column A ) on every sheet ( 12 ) and copy
that adjacent range of data without the formula to another workbook B
in each of 12 worksheets
at the next 5 rows of last used cells of column E
E.g. if there is "OP" in the mid of column A, select the current
region starts from column B to O
in sheet "ADP" ( out of 12 sheets ) under workbook A and copy (without
the formula ) paste to sheet"ADP" ( out of 12 sheets ) under workbook
B
at the next 5 rows of last used cells of column E
Below is the extract of draft excel vba code for a single sheet seems
to be incomplete as it copies row by row and does not work as
intended, further I have no idea how to design excel vba for multiple
sheets
Dim wsNew As Worksheet
Dim OpWs As Worksheet
Dim sTarget As String
Dim i As Integer
Sheets.Add Before:=Sheets(1)
Set OpWs = ActiveSheet
Workbooks.Open Filename:="C:\Budget Final\Acad\ADP.xls"
Windows("ADP.xls").Activate
Set wsNew = Sheets("P+L")
sTarget = "OP"
With Worksheets("P+L")
iLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = 1 To iLastRow
If .Cells(i, "A").Value = sTarget Then
iNextRow = iNextRow + 1
.Rows(i).Copy OpWs.Cells(iNextRow, "A")
End If
Next i
End With
Appreciate any help to solve the above problem as I'm excel vba
beginner
Many thanks
Warm regards
Len
I am copying a dynamic range of cells from 12 different worksheets
under workbook A.
I need to select an adjacent range that starts with "OP" ( always at
column A ) on every sheet ( 12 ) and copy
that adjacent range of data without the formula to another workbook B
in each of 12 worksheets
at the next 5 rows of last used cells of column E
E.g. if there is "OP" in the mid of column A, select the current
region starts from column B to O
in sheet "ADP" ( out of 12 sheets ) under workbook A and copy (without
the formula ) paste to sheet"ADP" ( out of 12 sheets ) under workbook
B
at the next 5 rows of last used cells of column E
Below is the extract of draft excel vba code for a single sheet seems
to be incomplete as it copies row by row and does not work as
intended, further I have no idea how to design excel vba for multiple
sheets
Dim wsNew As Worksheet
Dim OpWs As Worksheet
Dim sTarget As String
Dim i As Integer
Sheets.Add Before:=Sheets(1)
Set OpWs = ActiveSheet
Workbooks.Open Filename:="C:\Budget Final\Acad\ADP.xls"
Windows("ADP.xls").Activate
Set wsNew = Sheets("P+L")
sTarget = "OP"
With Worksheets("P+L")
iLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = 1 To iLastRow
If .Cells(i, "A").Value = sTarget Then
iNextRow = iNextRow + 1
.Rows(i).Copy OpWs.Cells(iNextRow, "A")
End If
Next i
End With
Appreciate any help to solve the above problem as I'm excel vba
beginner
Many thanks
Warm regards
Len