-
Some of the problems highlighted:
Sub MoveData()
Sheets("Grain2").Cells.ClearContents
Sheets("Hop2").Cells.ClearContents
DestnColumn = 1
For Each are In Recipe("Recipe").Columns(1).SpecialCells(xlCellTypeConstants, 2).Areas
'are.Select
Grain2DestnRow = 1: Hop2DestnRow = 1
For Each cll In are.Cells
'cll.Select
CurrentItem = Application.Trim(cll.Value)
Set GrainFound = Recipe("Inputs").Columns(1).Find(what:=CurrentItem, lookat:=xlWhole, LookIn:=xlFormulas, searchformat:=False)
If Not GrainFound Is Nothing Then
Sheets("Grain2").Cells(GrainDestnRow, DestnColumn) = CurrentItem
GrainDestnRow = GrainDestnRow + 1
End If
Set HopsFound = Recipe("Inputs").Columns(3).Find(what:=cll.Value, lookat:=xlWhole, LookIn:=xlFormulas, searchformat:=False) 'my mistake:cll.value should be CurrentItem, but it wouldn't have mattered.
If Not HopsFound Is Nothing Then
Sheets("Hops2").Cells(HopsDestnRow, DestnColumn) = CurrentItem
HopsDestnRow = HopsDestnRow + 1
End If
Next cll
DestnColumn = DestnColumn + 1
Next are
End Sub
End Sub
How many columns will you be searching (curtrently only 2)? If more than 4 then there's probably some shorter code we can use.
p45cal
Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules