Paste Value Syntax in VBA

sscornav

Board Regular
Joined
Mar 20, 2010
Messages
125
Struggling with this one...

currentRow is a Range
destinationWorksheet is Worksheet

How do I copy with values and format by modifying this statement:

currentRow.Copy destinationWorksheet.Cells(rowNumber, "b")

New to VBA and struggling with Syntax....thanks!
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Option Explicit

Sub CopyRows()


Dim destinationWorksheet As Worksheet
Dim currentWorksheet As Worksheet
Dim currentRow As Range
Dim currentCell As Range
Dim rowNumber As Long

Set destinationWorksheet = Worksheets("XXX")

destinationWorksheet.Cells.Clear

rowNumber = 2 'start to paste at Row 2
For Each currentWorksheet In ActiveWorkbook.Worksheets
If currentWorksheet.Name <> destinationWorksheet.Name Then
For Each currentRow In currentWorksheet.UsedRange.Rows
For Each currentCell In currentRow.Cells
If Not IsError(currentCell) Then
If InStr(1, currentCell.Value, "XYZ", vbTextCompare) > 0 Then
If currentCell.Interior.Color = vbYellow Then
currentRow.Copy destinationWorksheet.Cells(rowNumber, "a")
rowNumber = rowNumber + 1
Exit For
End If
End If
End If
Next currentCell
Next currentRow
End If
Next currentWorksheet

destinationWorksheet.Activate

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,171
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top