Consulting

Results 1 to 4 of 4

Thread: transferring a column from sheet to sheet with the help of button

  1. #1
    VBAX Newbie
    Joined
    Jun 2020
    Posts
    3
    Location

    Question transferring a column from sheet to sheet with the help of button

    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
    Last edited by Paul_Hossler; 06-28-2020 at 11:35 AM. Reason: CODE tags

  2. #2
    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
    Last edited by jolivanes; 06-28-2020 at 11:37 AM. Reason: Add code

  3. #3
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    @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
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  4. #4
    VBAX Newbie
    Joined
    Jun 2020
    Posts
    3
    Location
    Sorry for code tags this one is my first question. First suggestions solved my problem, thanks a lot

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •