PDA

View Full Version : [SOLVED:] transferring a column from sheet to sheet with the help of button



arya96
06-28-2020, 10:59 AM
Hi Everyone,
I'm working on a formula to move data from one sheet to another. The code is worked when user click the button and the button is in a form. I have two sheet and I want to transfer sheet1 D2 to D18 to sheet2 E22 to E38 but the system keeps failing. I wrote down the code


Private Sub ComButsatınalma_yazdır_Click()
With Sheets("sipkalem")
Range("D2: D18").Copy Worksheets("SATINALMA FORM").Cells("E22:E38")
End With
End Sub

sipkalem= sheet1
SATINALMA FORM= sheet2

Thanks for your help

jolivanes
06-28-2020, 11:31 AM
Try

Private Sub ComButsatınalma_yazdır_Click()
With Sheets("sipkalem")
.Range("D2:D18").Copy Worksheets("SATINALMA FORM").Range("E22")
End With
End Sub

Or, for values only

Private Sub ComButsatınalma_yazdır_Click()
Worksheets("SATINALMA FORM").Range("E22:E38").Value = Worksheets("sipkalem").Range("D2: D18").Value
End Sub

Please use code tags for ease of reading/copying

Paul_Hossler
06-28-2020, 11:35 AM
@arya96 --

Note the 'dot' in from of the Range("D2 : D18")

The use of the dot inside of a With / End With connects to the object in the 'With', Sheets ("sipkalem"), in the case

Otherwise just Range (no dot) will refer to whatever the ActiveSheet happens to be

The [#] on the toolbar will insert [ CODE ] and [ /CODE] tags so you can paste your macro between. It sets it off and formats your macro nicely

arya96
06-28-2020, 11:50 AM
Sorry for code tags this one is my first question. First suggestions solved my problem, thanks a lot :)