Excel VBA - Copy/Paste Values per Criteria









up vote
-1
down vote

favorite












How do I copy just the values of a range to destination. Here is my code below. Any suggestions would be appreciated.



If ActiveSheet.Range("H2") = Sheets("RAW DATA").Range("E2") Then
On Error GoTo 0
refreshData
Selection.AutoFilter
Else

Dim r As Range
Dim LastRow As Long, i As Long, ws2 As Worksheet

With Worksheets("RAW DATA")

With Worksheets("RAW DATA")
.AutoFilterMode = False
.Range("G10").AutoFilter Field:=7, Criteria1:="N"
With .AutoFilter.Range
On Error Resume Next
Set r = .Resize(.Rows.Count - 1, 5).Offset(1, 1).SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If Not r Is Nothing Then
r.copy Worksheets("ORDER QUEUE").Range("F11" & .Rows.Count).End(xlUp).Offset(1, 0)
End If
End With
.AutoFilterMode = False
End With

End With

End If


I'm specifically looking to copy values w/o using PasteSpecial.










share|improve this question



















  • 3




    I dont see a question in your question
    – urdearboy
    Nov 9 at 20:44










  • Possible duplicate of Excel VBA Copy Paste Values only( xlPasteValues )
    – urdearboy
    Nov 9 at 20:52






  • 2




    You have a few issues with your With blocks. First, you have With Worksheets("RAW DATA") back to back. Also, when detereming the last row on ORDER QUEUE you are actually looking at the wrong sheet since you apply the with block to .Rows.Count. Also, you have a few unneccsary error traps here. No need to error trap Set r = ... - You are already checking for the error with If Not r is Nothing Then
    – urdearboy
    Nov 9 at 20:54










  • @urdearboy thanks for pointing out the things above; however, i'm specifically looking for a way to copy value to a destination without using 'PasteSpecial' - if possible.
    – user10630747
    Nov 9 at 21:26







  • 1




    See Range.Value equal to each other
    – urdearboy
    Nov 9 at 21:46














up vote
-1
down vote

favorite












How do I copy just the values of a range to destination. Here is my code below. Any suggestions would be appreciated.



If ActiveSheet.Range("H2") = Sheets("RAW DATA").Range("E2") Then
On Error GoTo 0
refreshData
Selection.AutoFilter
Else

Dim r As Range
Dim LastRow As Long, i As Long, ws2 As Worksheet

With Worksheets("RAW DATA")

With Worksheets("RAW DATA")
.AutoFilterMode = False
.Range("G10").AutoFilter Field:=7, Criteria1:="N"
With .AutoFilter.Range
On Error Resume Next
Set r = .Resize(.Rows.Count - 1, 5).Offset(1, 1).SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If Not r Is Nothing Then
r.copy Worksheets("ORDER QUEUE").Range("F11" & .Rows.Count).End(xlUp).Offset(1, 0)
End If
End With
.AutoFilterMode = False
End With

End With

End If


I'm specifically looking to copy values w/o using PasteSpecial.










share|improve this question



















  • 3




    I dont see a question in your question
    – urdearboy
    Nov 9 at 20:44










  • Possible duplicate of Excel VBA Copy Paste Values only( xlPasteValues )
    – urdearboy
    Nov 9 at 20:52






  • 2




    You have a few issues with your With blocks. First, you have With Worksheets("RAW DATA") back to back. Also, when detereming the last row on ORDER QUEUE you are actually looking at the wrong sheet since you apply the with block to .Rows.Count. Also, you have a few unneccsary error traps here. No need to error trap Set r = ... - You are already checking for the error with If Not r is Nothing Then
    – urdearboy
    Nov 9 at 20:54










  • @urdearboy thanks for pointing out the things above; however, i'm specifically looking for a way to copy value to a destination without using 'PasteSpecial' - if possible.
    – user10630747
    Nov 9 at 21:26







  • 1




    See Range.Value equal to each other
    – urdearboy
    Nov 9 at 21:46












up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











How do I copy just the values of a range to destination. Here is my code below. Any suggestions would be appreciated.



If ActiveSheet.Range("H2") = Sheets("RAW DATA").Range("E2") Then
On Error GoTo 0
refreshData
Selection.AutoFilter
Else

Dim r As Range
Dim LastRow As Long, i As Long, ws2 As Worksheet

With Worksheets("RAW DATA")

With Worksheets("RAW DATA")
.AutoFilterMode = False
.Range("G10").AutoFilter Field:=7, Criteria1:="N"
With .AutoFilter.Range
On Error Resume Next
Set r = .Resize(.Rows.Count - 1, 5).Offset(1, 1).SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If Not r Is Nothing Then
r.copy Worksheets("ORDER QUEUE").Range("F11" & .Rows.Count).End(xlUp).Offset(1, 0)
End If
End With
.AutoFilterMode = False
End With

End With

End If


I'm specifically looking to copy values w/o using PasteSpecial.










share|improve this question















How do I copy just the values of a range to destination. Here is my code below. Any suggestions would be appreciated.



If ActiveSheet.Range("H2") = Sheets("RAW DATA").Range("E2") Then
On Error GoTo 0
refreshData
Selection.AutoFilter
Else

Dim r As Range
Dim LastRow As Long, i As Long, ws2 As Worksheet

With Worksheets("RAW DATA")

With Worksheets("RAW DATA")
.AutoFilterMode = False
.Range("G10").AutoFilter Field:=7, Criteria1:="N"
With .AutoFilter.Range
On Error Resume Next
Set r = .Resize(.Rows.Count - 1, 5).Offset(1, 1).SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If Not r Is Nothing Then
r.copy Worksheets("ORDER QUEUE").Range("F11" & .Rows.Count).End(xlUp).Offset(1, 0)
End If
End With
.AutoFilterMode = False
End With

End With

End If


I'm specifically looking to copy values w/o using PasteSpecial.







excel vba excel-vba






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 at 7:19









Pᴇʜ

19.2k42650




19.2k42650










asked Nov 9 at 20:41









user10630747

11




11







  • 3




    I dont see a question in your question
    – urdearboy
    Nov 9 at 20:44










  • Possible duplicate of Excel VBA Copy Paste Values only( xlPasteValues )
    – urdearboy
    Nov 9 at 20:52






  • 2




    You have a few issues with your With blocks. First, you have With Worksheets("RAW DATA") back to back. Also, when detereming the last row on ORDER QUEUE you are actually looking at the wrong sheet since you apply the with block to .Rows.Count. Also, you have a few unneccsary error traps here. No need to error trap Set r = ... - You are already checking for the error with If Not r is Nothing Then
    – urdearboy
    Nov 9 at 20:54










  • @urdearboy thanks for pointing out the things above; however, i'm specifically looking for a way to copy value to a destination without using 'PasteSpecial' - if possible.
    – user10630747
    Nov 9 at 21:26







  • 1




    See Range.Value equal to each other
    – urdearboy
    Nov 9 at 21:46












  • 3




    I dont see a question in your question
    – urdearboy
    Nov 9 at 20:44










  • Possible duplicate of Excel VBA Copy Paste Values only( xlPasteValues )
    – urdearboy
    Nov 9 at 20:52






  • 2




    You have a few issues with your With blocks. First, you have With Worksheets("RAW DATA") back to back. Also, when detereming the last row on ORDER QUEUE you are actually looking at the wrong sheet since you apply the with block to .Rows.Count. Also, you have a few unneccsary error traps here. No need to error trap Set r = ... - You are already checking for the error with If Not r is Nothing Then
    – urdearboy
    Nov 9 at 20:54










  • @urdearboy thanks for pointing out the things above; however, i'm specifically looking for a way to copy value to a destination without using 'PasteSpecial' - if possible.
    – user10630747
    Nov 9 at 21:26







  • 1




    See Range.Value equal to each other
    – urdearboy
    Nov 9 at 21:46







3




3




I dont see a question in your question
– urdearboy
Nov 9 at 20:44




I dont see a question in your question
– urdearboy
Nov 9 at 20:44












Possible duplicate of Excel VBA Copy Paste Values only( xlPasteValues )
– urdearboy
Nov 9 at 20:52




Possible duplicate of Excel VBA Copy Paste Values only( xlPasteValues )
– urdearboy
Nov 9 at 20:52




2




2




You have a few issues with your With blocks. First, you have With Worksheets("RAW DATA") back to back. Also, when detereming the last row on ORDER QUEUE you are actually looking at the wrong sheet since you apply the with block to .Rows.Count. Also, you have a few unneccsary error traps here. No need to error trap Set r = ... - You are already checking for the error with If Not r is Nothing Then
– urdearboy
Nov 9 at 20:54




You have a few issues with your With blocks. First, you have With Worksheets("RAW DATA") back to back. Also, when detereming the last row on ORDER QUEUE you are actually looking at the wrong sheet since you apply the with block to .Rows.Count. Also, you have a few unneccsary error traps here. No need to error trap Set r = ... - You are already checking for the error with If Not r is Nothing Then
– urdearboy
Nov 9 at 20:54












@urdearboy thanks for pointing out the things above; however, i'm specifically looking for a way to copy value to a destination without using 'PasteSpecial' - if possible.
– user10630747
Nov 9 at 21:26





@urdearboy thanks for pointing out the things above; however, i'm specifically looking for a way to copy value to a destination without using 'PasteSpecial' - if possible.
– user10630747
Nov 9 at 21:26





1




1




See Range.Value equal to each other
– urdearboy
Nov 9 at 21:46




See Range.Value equal to each other
– urdearboy
Nov 9 at 21:46

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53232992%2fexcel-vba-copy-paste-values-per-criteria%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53232992%2fexcel-vba-copy-paste-values-per-criteria%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Use pre created SQLite database for Android project in kotlin

Darth Vader #20

Ondo