Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Old April 4th 07, 11:38 PM posted to microsoft.public.excel.programming
external usenet poster
 
First recorded activity by ExcelBanter: Apr 2007
Posts: 7
Default 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


  #2   Report Post  
Old April 5th 07, 12:50 AM posted to microsoft.public.excel.programming
external usenet poster
 
First recorded activity by ExcelBanter: Jul 2006
Posts: 3,986
Default 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


  #3   Report Post  
Old April 5th 07, 01:12 AM posted to microsoft.public.excel.programming
external usenet poster
 
First recorded activity by ExcelBanter: Jul 2006
Posts: 3,986
Default 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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
column data retrieved based on value in header row Tomkat743 Excel Discussion (Misc queries) 2 March 4th 09 04:17 AM
Copy data from other worksheet based on column header [email protected] Excel Discussion (Misc queries) 0 April 29th 08 08:18 PM
Based on a condition in one column, search for a year in another column, and display data from another column in the same row look [email protected] Excel Programming 2 December 30th 06 06:23 PM
Based on a condition in one column, search for a year in another column, and display data from another column in the same row look [email protected] Excel Discussion (Misc queries) 1 December 27th 06 05:47 PM
How do I move data based on a conditional column search? bbaek Excel Programming 1 May 27th 05 04:17 PM


All times are GMT +1. The time now is 04:52 AM.

Powered by vBulletin® Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
Copyright 2004-2021 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"

 

Copyright © 2017