Copy/Paste Value Only to New Worksheet

LBinGA

Board Regular
Joined
Jan 29, 2014
Messages
57
Hello all:

I'm trying to copy & paste into another sheet the value ONLY from Input!B36 but the xlPasteValues is not working. It continues to produces #N/A as a result AND it strips the copied from sheet of the formula. I'd like to copy the Value only from the Input Sheet over to the Bordereau Sheet.

Code:
Sub CopytoBord()

Dim ws As Worksheet
Dim ws2 As Worksheet
Dim rngCopyIns
Dim rngCopyFinal As Range
Dim rngPaste As Range
Dim LR As Long


Set ws = Worksheets("Input")
Set ws2 = Worksheets("Bordereau")




ActiveSheet.Unprotect


If ws.Range("J11").Value = "BOUND" Then
'***Copy Insured Name
Set rngCopyIns = ws.Range("C5:K5")
If ws2.Range("A2").Value = "" Then
    Set rngPaste = ws2.Range("A2")
Else
    LR = ws2.Cells(Rows.Count, "A").End(xlUp).Row + 1
    Set rngPaste = ws2.Range("A" & LR)
End If


rngCopyIns.Copy
rngPaste.PasteSpecial xlPasteValues
rngCopyIns.Value = ""
rngCopyIns.Cells(1).Select
Application.CutCopyMode = False


'****copy Final Cost
Set rngCopyFinal = ws.Range("B36")
If ws2.Range("K2").Value = "" Then
    Set rngPaste = ws2.Range("K2")
Else
    LR = ws2.Cells(Rows.Count, "K").End(xlUp).Row + 1
    Set rngPaste = ws2.Range("K" & LR)
End If


rngCopyFinal.Copy
rngPaste.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
rngCopyFinal.Value = ""
rngCopyFinal.Cells(1).Select
Application.CutCopyMode = False




Else
MsgBox "Must have Bound Status to move to Bordereau"
End If


ActiveSheet.Protect


End Sub

What am I missing?

Thanks,
LBinGA
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
I know this looks like it should work but it doesn't. I've been struggling with it all day. It continues to produce an "#N/A" result.
Any thoughts or help would be appreciated.

Thanks,
LB
 
Upvote 0
I'm trying to copy & paste into another sheet the value ONLY from Input!B36 but the xlPasteValues is not working. It continues to produces #N/A as a result

Here's the relevant bit of your code ....

Code:
Set rngCopyFinal = ws.Range("B36")
' ....
rngCopyFinal.Copy
rngPaste.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
rngCopyFinal.Value = ""

If rngPaste ends up with the value #N/A, then ws.Range("B36") had an #N/A value before the copy. I suggest you put in a breakpoint and check out why.

AND it strips the copied from sheet of the formula.

.... because of the last line in this code snippet!
 
Upvote 0
rngCopyFinal = ws.Range("B36") is a Linked field, which links back to a Calculated field (=MAX(J26:J29)) on a 3rd Worksheet called Calculations. The formula is functioning properly and a figure appears in both it and in B36 on the Input sheet. If I cut/pastespecial values manually, the value pastes, no problem.

I've tried moving it directly from the Calculations sheet and the calculated field (J31) but it produces the same result, #N/A, even though there is a figure in the field. That looks like this:

Code:
'****copy FINAL
Set rngCopyFinal = ws3.Range("J31")
If ws2.Range("K2").Value = "" Then
    Set rngPaste = ws2.Range("K2")
Else
    LR = ws2.Cells(Rows.Count, "K").End(xlUp).Row + 1
    Set rngPaste = ws2.Range("K" & LR)
End If

rngCopyFinal.Copy
rngPaste.PasteSpecial xlPasteValues
rngCopyIns.Cells(1).Select
Application.CutCopyMode = False

I get the last line thing...now...duh. Thanks.

Any thoughts on the why B36, which is linked back to a calculated field with a valid number is giving the #N/A response when I'm using pastespecial?

Thanks,
LB
 
Last edited:
Upvote 0
Any thoughts on the why B36, which is linked back to a calculated field with a valid number is giving the #N/A response when I'm using pastespecial?

Are you sure that when this piece of code runs, B36 doesn't have an #N/A value. Put in a Stop or a breakpoint and have a look.

My guess is that B36 starts out OK, but your intervening code messes something up. This looks suspicious, for example:

rngCopyIns.Value = ""

Did you mean to clear this range? Are any of your formulae dependent on this range?
 
Upvote 0
Are you sure that when this piece of code runs, B36 doesn't have an #N/A value. Put in a Stop or a breakpoint and have a look.

My guess is that B36 starts out OK, but your intervening code messes something up. This looks suspicious, for example:

rngCopyIns.Value = ""

Did you mean to clear this range? Are any of your formulae dependent on this range?

You're absolutely right. The calculations depends on those fields being completed and that line was removing the selection and changing it to #N/A.

Thank you...SO much.

LB
 
Upvote 0

Forum statistics

Threads
1,214,426
Messages
6,119,414
Members
448,895
Latest member
omarahmed1

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