ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Search for a column based on the column header and then past data from it to another column in another workbook (https://www.excelbanter.com/excel-programming/386877-search-column-based-column-header-then-past-data-another-column-another-workbook.html)

minkokiss

Search for a column based on the column header and then past data from it to another column in another workbook
 
Hey guys I am trying to develop a macro that will search for specific
column header names in an opened workbook, if the header is found I
will get the data from the column data under the header and paste in
into another column in another Workbook without specifying formating.
Any help for that would be great. Thank you

minkokiss


JLGWhiz

Search for a column based on the column header and then past data
 
I did not test this, so you should before using in the original workbook.

Sub FindCopyPaste()
myHdr = Cells(1, Columns.Count).End(xlToLeft).Column
myRng = Range(Cells(1, 1), Cells(1, myHdr))
With myRng
Set c = .Find("HeaderName", After:=myHdr, Lookin:=xlValues)
If Not c Is Nothing Then
xRng = c.Address
Range(xRng).Offset(1, 0).EntireColumn.Copy
Workbooks("DifferentOne").Sheets("Whatever").Range ("$A$1")
End If
End With
End Sub

"minkokiss" wrote:

Hey guys I am trying to develop a macro that will search for specific
column header names in an opened workbook, if the header is found I
will get the data from the column data under the header and paste in
into another column in another Workbook without specifying formating.
Any help for that would be great. Thank you

minkokiss



JLGWhiz

Search for a column based on the column header and then past data
 
This is actually one line in code:

Range(xRng).Offset(1, 0).EntireColumn.Copy
Workbooks("DifferentOne").Sheets("Whatever").Range ("$A$1")

There is a space between Copy and Workbooks.

"minkokiss" wrote:

Hey guys I am trying to develop a macro that will search for specific
column header names in an opened workbook, if the header is found I
will get the data from the column data under the header and paste in
into another column in another Workbook without specifying formating.
Any help for that would be great. Thank you

minkokiss




All times are GMT +1. The time now is 08:20 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com