destination paste to Table >>ONLY VALUE

a_t_a

New Member
Joined
Nov 22, 2017
Messages
10
hi
when i press save button ,

my value pastet to sheet "data" With border

i want past to data sheet without any border , just value

download file :
https://ufile.io/ql5uk


PHP:
Sub Rectangle2_Click()
 
z1 = Range("B5").End(xlDown).Row

z2 = Sheets("Data").Cells(Sheets("Data").Rows.Count, "c").End(xlUp).Row + 1

Range("b6:e" & z1).Copy Destination:=Sheets("Data").Range("c" & z2) 'problem here

z3 = Sheets("Data").Cells(Sheets("Data").Rows.Count, "c").End(xlUp).Row

For i = z2 To z3

Sheets("Data").Range("b" & i) = Range("b2") '
Next

MsgBox ("succ")
End Sub
tanx
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
One way is to attribute values from one range to the other

Code:
Sub Rectangle2_Click()
    Dim z1 As Long, z2 As Long, z3 As Long, i As Long
    [COLOR=#ff0000]Dim rng1 As Range, rng2 As Range[/COLOR]
    
    z1 = Range("B5").End(xlDown).Row
    z2 = Sheets("Data").Cells(Sheets("Data").Rows.Count, "c").End(xlUp).Row + 1
[COLOR=#ff0000]    Set rng1 = Range("b6:e" & z1)
    Set rng2 = Sheets("Data").Range("c" & z2).Resize(rng1.Rows.Count, rng1.Columns.Count)[/COLOR]
    [COLOR=#ff0000]rng2.Value = rng1.Value[/COLOR]
    z3 = Sheets("Data").Cells(Rows.Count, "c").End(xlUp).Row
    For i = z2 To z3
       Sheets("Data").Range("b" & i) = Range("b2")
    Next

    MsgBox ("succ")
End Sub

Variable declaration made for ALL varables
- declaring variables is voluntary ;)
- can help you spot problems in your code
 
Last edited:
Upvote 0
and ...
... to avoid an unnecessary loop (which makes code slower)

replace
Code:
    For i = z2 To z3
       Sheets("Data").Range("b" & i) = Range("b2")
    Next
with
Code:
    Sheets("Data").Range("b" & z2).Resize(z3 - z2 + 1) = Range("b2")
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
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