Paste to Headers

metalogic

New Member
Joined
Jun 20, 2024
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hello,

I have the following VBA code which pastes information from one worksheet to another worksheet based on defined criteria. The two worksheets have different headings, and I need the information to paste according to the headings. How do I modify this code in order for that to happen?

Sub Awarded()
Dim fCell As Range
Dim wsSearch As Worksheet
Dim wsDest As Worksheet

'What sheet are we searching?
Set wsSearch = Worksheets("SALES FUNNEL")
'Where should we move the data?
Set wsDest = Worksheets("AWARDED")

'Prevent screen flicker
Application.ScreenUpdating = False

'We will be searching col I
With wsSearch.Range("I:I")
'Find the word "Awarded"
Set fCell = .Find(what:="Awarded", LookIn:=xlValues, lookat:=xlWhole, MatchCase:=False)

'Repeat until we've moved all the records
Do Until fCell Is Nothing
'Found something, copy and delete
fCell.EntireRow.Copy Destination:=wsDest.Cells(.Rows.Count, "A").End(xlUp).Offset(1)
fCell.EntireRow.Delete

'Try to find next one
Set fCell = .Find(what:="Awarded", LookIn:=xlValues, lookat:=xlWhole, MatchCase:=False)
Loop
End With

'Reset
Application.ScreenUpdating = True

End Sub
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
It would be easier to help if you could use the XL2BB add-in (icon in the menu) to attach screenshots (not pictures) of your 2 sheets. Alternately, you could upload a copy of your file to a free site such as www.box.com or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. Explain in detail what you want to do referring to specific cells, rows, columns and sheets using a few examples from your data (de-sensitized if necessary).
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top