mdonovan890
New Member
- Joined
- Dec 22, 2016
- Messages
- 24
Hello,
Below is the code that I am currently using to copy all the rows on each of the specified worksheets based upon a single criteria (Column N="Y"). The Marco then pastes these rows as values on Sheet 4. This code functions properly however, it is extremely slow. The verison of Excel that I working in is 32 BIT Excel 2016.I am hoping to get some suggestions on how to make this VBA run more efficiently. Many thanks!
Public Sub COPYOUSDATA()
Dim ws As Worksheet
Dim destinationWorksheet As Worksheet
Dim columnN As Range
Dim c As Range
Dim count As Long
Set destinationWorksheet = ActiveWorkbook.Worksheets("Sheet4")
destinationWorksheet.Cells.ClearContents
count = 1
For Each ws In ActiveWorkbook.Worksheets
If ws.Name = "{OUS Region A} Europe" Or ws.Name = "{OUS Region B} Asia-Pacific" Or ws.Name = "{OUS Region C} Latin America"
Set columnN = ws.Range("N:N") 'columnN
For Each c In columnN
If WorksheetFunction.IsText(c.Value) Then
If InStr(c.Value, "Y") > 0 Then
c.EntireRow.Copy
destinationWorksheet.Cells(count, 1).PasteSpecial xlPasteValuesAndNumberFormats
count = count + 1
End If
End If
Next c
End If
Next ws
End Sub
Below is the code that I am currently using to copy all the rows on each of the specified worksheets based upon a single criteria (Column N="Y"). The Marco then pastes these rows as values on Sheet 4. This code functions properly however, it is extremely slow. The verison of Excel that I working in is 32 BIT Excel 2016.I am hoping to get some suggestions on how to make this VBA run more efficiently. Many thanks!
Public Sub COPYOUSDATA()
Dim ws As Worksheet
Dim destinationWorksheet As Worksheet
Dim columnN As Range
Dim c As Range
Dim count As Long
Set destinationWorksheet = ActiveWorkbook.Worksheets("Sheet4")
destinationWorksheet.Cells.ClearContents
count = 1
For Each ws In ActiveWorkbook.Worksheets
If ws.Name = "{OUS Region A} Europe" Or ws.Name = "{OUS Region B} Asia-Pacific" Or ws.Name = "{OUS Region C} Latin America"
Set columnN = ws.Range("N:N") 'columnN
For Each c In columnN
If WorksheetFunction.IsText(c.Value) Then
If InStr(c.Value, "Y") > 0 Then
c.EntireRow.Copy
destinationWorksheet.Cells(count, 1).PasteSpecial xlPasteValuesAndNumberFormats
count = count + 1
End If
End If
Next c
End If
Next ws
End Sub