• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA code to copy from one sheet to another.

shuganth

New Member
I am new to VBA, I need a code for when I click a button the entire A column will be copied from sheet 1 and pasted in another sheet 'A' column and when I click the button again it should copy the same and paste it in B column. Can you please help me. Thanks
 
shuganth
Is that another sheet any know name or something?
With again click ... which column should be copied - A-column from sheet 1 or from another sheet A-column?
 
I am new to VBA, I need a code for when I click a button the entire A column will be copied from sheet 1 and pasted in another sheet 'A' column and when I click the button again it should copy the same and paste it in B column. Can you please help me. Thanks
Can you please show us example and let me know why you want to do one column after column
 
shuganth
Is that another sheet any know name or something?
With again click ... which column should be copied - A-column from sheet 1 or from another sheet A-column?

Like Consider that I am have sheet1 where the 'A' column has values , if I click a button it should paste in empty first column in sheet 2 and if I click the button again in sheet 1 the same 'A' column should get copied and pasted in sheet 2 first empty column and the same as long as I press the button.

Note: The values in sheet1 A column are dynamic so it needs to be copied everytime I click the button.

Thank you very much Vletm
 
Can you please show us example and let me know why you want to do one column after column
Like Consider that I have a sheet1 where the 'A' column has values , if I click a button it should paste in empty first column in sheet 2 and if I click the button again in sheet 1 the same 'A' column should get copied and pasted in sheet 2 's first empty column and the same as long as I press the button.

Note: The values in sheet1 A column are dynamic so it needs to be copied every time when I click the button to store the dynamic values as static in a time period.
 
I just found this code all I need now is to time stamp the column at 'C1' of eveytime when the button is clicked please help

>>> use code - tags <<<
Code:
Sub Button2_Click()

    Dim source As Worksheet
    Dim destination As Worksheet
    Dim emptyColumn As Long

    Set source = Sheets("Sheet1")
    Set destination = Sheets("Sheet2")

    'find empty Column (actually cell in Row 1)'
    emptyColumn = destination.Cells(1, destination.Columns.Count).End(xlToLeft).Column + 1

    If destination.Cells(1, 1) = "" And emptyColumn = 2 Then emptyColumn = 1

    source.Range("a1:a35").Copy destination.Cells(1, emptyColumn)

End Sub
 
shuganth
Even above code will do as it has asked to do.
Test this sample
- press [ Do It ]-button.
Thank you very much vletm, this is perfect but I am facing one difficulty all the values which I copy from the column are the average of few columns so I'm getting #ref! can you please add the paste value to it when I try adding it its throwing me error and can you help me to add month on everytime when I click the button , Column 1 will have the month followed by the values that are to be pasted. Thank you very much this means a lot .
 
shuganth
Did You ask to copy only values (Your original writing)?
What do You write about add month?
You should able to upload an Excel-file, which has a sample data, as well as what do You really would like to get?
If You think something and You write something else then You'll get that something else as You've written.
 
Sorry for not being clear I have attached the sample sheet please help me vletm. Thanks
 

Attachments

  • test.xlsx
    12.7 KB · Views: 6
shuganth
Based You carefully made file ...
... what was Your challenge with my sample file?
Your files Sheet1 A-column has ... names ... texts.
 
Back
Top