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

Modified the Macro

Status
Not open for further replies.

Abhijeet

Active Member
Hi
I have macro match headers in sheet 2 with sheet1 data if match then give below the data.If macro button in sheet3 then this macro not work can please tell me how to do this
 

Attachments

  • Irfan.xls
    40.5 KB · Views: 1
First, the macro doesn't have to work so hard. If just matching column headers, then you can use the AdvancedFilter.
Code:
Sub CopyData()

Dim PstRng As Range
Dim CopyRange As Range

Set CopyRange = Sheet1.UsedRange
With ActiveSheet

    'Where are we copying to
    Set PstRng = Intersect(.UsedRange, .Range("1:1"))
    'Clear old data
    .Range("2:" & .Rows.Count).EntireRow.ClearContents
    'Copy via Filter
    CopyRange.AdvancedFilter xlFilterCopy, , PstRng
End With
MsgBox "Done"
End Sub

That being said, the reason it didn't work on Sheet3 is because you didn't have any column headers and previous macro needed some. My macro here will assume you want all column headers if blank, so should also work for you.
 
This topic is the same as last question of this, just a few minutes of difference:
http://chandoo.org/forum/threads/match-the-headers-and-paste-data.15797/

What you're doing "is called cross-posting and is generally frowned upon in the Blogosphere as it causes people to potentially waste our time when a question is already answered or to disperse our efforts thru repeated threads on the same subject. You should also check and respond to posts and let posters know if they are heading in the write direction or not." Hui's dixit, SIC. And I agree 101%.

If you'd have read the main green sticky post at this forums main page...
http://chandoo.org/forum/threads/new-users-please-read.294/
...you should have noticed this points:

"Consider that the world is operating 24hrs a day. A late post today may well be answered by someone else overnight."

"If you and a reader have been involved in an ongoing conversation and the conversation suddenly stops, recognize that the person may have gone to bed, even though you have just arrived at work. In the worst case a reader may go on holidays and not get back to the question for a few days."

"Never title your posts as "Urgent", "Priority" "Immediate". It may be Important to you, but not for rest of the members here. These words will be moderated out."

"Cross Posting, generally it is considered poor practice to cross post, that is to post the same question on several forums in the hope of getting a response quicker.
If you do cross post, please put that in your post.
Also if you have cross posted and get an answer elsewhere, have the courtesy of posting the answer here so other readers can learn from the answer also, as well as stopping people wasting there time on your answered question."

"Say "Thanks", whenever you can. Recognize when someone has bothered to go to the trouble and time to assist you with your question for free. Often readers will spend several hours working on a solution to a problem, a line of recognition will go a long way."
end several hours working on a solution to a problem, a line of recognition will go a long way."

Regards!

PS: If it's a high priority issue and you can't even wait... how much?... oh, 2 hours and a while... absolutely unbearable... but you always have the alternative of hiring a local consultant who may provide you the exact tailored service. Should I remember you that these forums are supported by contributors who dedicate part of their time in an absolutely free way to help other people and answer questions?
 
Status
Not open for further replies.
Back
Top