Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying columns from one sheet to another and accounting for data in the destination columns 1

Status
Not open for further replies.

regsamp

IS-IT--Management
Sep 23, 2015
4
US
How can I have the code below move the Copy Destination to Columns C and D if the destination Columns A and B have data in them? And if there is data in Columns C and D, copy to E and F, and so on?


Public Sub My_Copy()

Sheets("Sheet2").Columns("A:B").Copy Destination:=Sheets("Sheet1").Range("A:B")

End Sub
 
hi,

This seems to be VBA, not VBScript????? Forum707.
ALSO your data appears to have no table headings, normally seen in ROW 1???
Code:
Public Sub My_Copy()

    With Sheets("Sheet1")
        Sheets("Sheet2").UsedRange.Copy Destination:=.Cells(.UsedRange.Rows.Count + 1, "A")
    End With

End Sub


Skip,

[glasses]Just traded in my OLD subtlety...
for a NUance![tongue]
 
It is VBA. I apologize as I picked the wrong forum. I am trying to get a button that copies from the "Revisions" sheet, the columns of B, C, and D into the Title_Frame_Register sheet columns with the Headers, "Revision Date", "Revision Description", and "Checked By".

If the columns have data in them, they would move to the next empty columns with those headers.

So in the example, if AU, AV and AX on the "Title_Frame_Register sheet has data the copy of B, C and D from the "Revisions" sheet, the macro will move to the AZ, BA and BB of the "Title_Frame_Register Sheet.

And so on.
 
Well first, you specify that's what you're trying to do. That's NOT what your code indicates! Just posting code, do not get the job done, as per OP...
Code:
Public Sub My_Copy()
    Dim ws1 As Worksheet
    
    Set ws1 = Sheets("Sheet1")
    
    With Sheets("Sheet2")
        .Range(.Cells(2, "A"), .Cells(.UsedRange.Rows.Count, .UsedRange.Columns.Count)).Copy _
            Destination:=ws1.Cells(ws1.UsedRange.Rows.Count + 1, "A")
    End With

    Set ws1 = Nothing
End Sub


Skip,

[glasses]Just traded in my OLD subtlety...
for a NUance![tongue]
 
Okay. Sorry for the confusion. It is my first post. Should I just delete it and go to the other forum?
 
No, it is noted, and welcome to Tek-Tips. You'll find lots of good stuff here.

Any other questions regarding VBA, though, ought to be posted in forum707.

Skip,

[glasses]Just traded in my OLD subtlety...
for a NUance![tongue]
 
Thank you. I appreciate your help. I am brand new to the forum and VBA in general so I am sorry again for the confusion. Thank you again for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top