Consulting

Results 1 to 5 of 5

Thread: VBA : Input form : Copy column and paste special value in another column

  1. #1

    VBA : Input form : Copy column and paste special value in another column

    Hello


    I'm quite new to VBA .
    I'm trying to do a Input form with VBA


    I have 3 sheets

    Sheet1 : Input
    Sheet 2 : Sheet3
    Sheet 3 : Cal

    I have two macros which work with a insert button :


    Sheet1 = Input - Sub OneCell()
    Sheet2 = Sheet3 - Sub ok()


    Sub OneCell()
    Sheets("Input").Range("c3:c9").Copy Sheets("Sheet3").Range("b3:b9")
    Sheets("Input").Range("c3:c9").ClearContents
    End Sub

    and

    Sub ok()
    Sheets("Sheet3").Range("c3:c9").Copy
    Sheets("Cal").Range("c3:c9").PasteSpecial Paste:=xlPasteValues
    Sheets("Sheet3").Range("b3:b9").ClearContents
    End Sub

    For the Macro Sub ok(), I would like to have the same code but which will paste the value in the the following empty columns in Sheet Cal
    such as pasting the values starting in c3:c9 then pasting the following values in d3:d9 and so on

    Is what something possible ?


    Thanks in advance
    Last edited by Aussiebear; 10-11-2023 at 01:04 PM. Reason: Added code tags and reduced the whitespace

  2. #2
    VBAX Mentor
    Joined
    Nov 2022
    Location
    The Great Land
    Posts
    337
    Location
    Please post code between CODE tags to retain indentation and readablity. Use # icon on edit toolbar.

    Sure, most anything is possible. But I don't quite understand the "following values in d3:d9 and so on" requirement. What are "following values" and what is meant by "and so on". Perhaps you should attach file and include a sheet that shows what you result you want.
    How to attach file: Reading and Posting Messages (vbaexpress.com), click Go Advanced below post edit window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,059
    Location
    Welcome to VBAX Steenbok. When posting code to this forum, please wrap your code with code tags. See the first line in my signature as a hint to as how this is done.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  4. #4
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,059
    Location
    @June7. I think that Steenbok is wanting to paste the next lot of information in the next column over.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  5. #5
    Moderator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,198
    Location
    Will the below help?

    Sub ok()
        Sheets("Sheet3").Range("c3:c9").Copy
        Sheets("Cal").Cells(3, Columns.Count).End(xlToLeft).Offset(, 1).PasteSpecial xlValues
        Sheets("Sheet3").Range("b3:b9").ClearContents
    End Sub
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved
    Click here for a guide on how to upload a file with your post

    Excel 365, Version 2403, Build 17425.20146

Posting Permissions

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