• 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.

Copy columns based on column headings

Dee

Member
Hey All,

I am trying to copy few columns from one sheet to another or from one file to another using excel macros. It should pick the columns based on the column headings (EX: Emp Id, Location,Department etc.,).

Can any of the macro experts help me with macros.


Thanking you in advance,

Dee
 
This seems like it would be easier to do with a Data - Query, or an AdvancedFilter than using a macro...
 
Hey! Got it guys...


Thanks Luke, as i am not aware of query in excel i tried this...

If possible can you explain how it can be done in this case?


Sub copycolumns()


Dim rng As Range


Set rng = Sheets("Raw Data").Range("A1:IV1").Find("EMP ID", LookIn:=xlValues)


rng.Offset(1, 0).Resize(rng.End(xlDown).Row - 1).Copy


Set rng = Sheets("Results").Range("A1:IV1").Find("EMP ID", LookIn:=xlValues)


rng.Offset(1, 0).PasteSpecial (xlPasteAll)


End Sub
 
hey guys...

even though i got this...i have one more requirement.

In the above codes i can look for only one column header and copy it but i need to check more 3-4 columns and copy it...


Can any one of help me on this...


Thanks,

Dee
 
Back
Top