VBA Help with copy Specific Cells to another Sheet

DJMXM

New Member
Joined
Jun 19, 2013
Messages
45
Hello All - I am working on the next part of my Monster and I am starting to build a VBA Module to copy over data from one sheet to another based on choices. I got a good part of it working but I need to copy one set of choices from a specific area of the sheet and add them to the list that already exists in the 2nd sheet. I am posting the code below. What I need help with is, I only need to look at data in Rows 81:85 and if TRUE in Column AI then I need to copy only cells AB, AC, AF, AG. I hope I am making sense. The code below works but copies everything that is true from column "AI" and I only need to look at rows 81:85 - I hope you can help.

Mike

Code:
Sub BEOLiquorManualList()

    Dim wsSource As Worksheet, wsDest As Worksheet
    Dim FoundX As Range, Firstfound As String, Lastrow As Long
    
    Set wsSource = Worksheets("Catering and Rental Worksheet")     ' Source worksheet
    Set wsDest = Worksheets("Catering BEO")       ' Destination worksheet
    
    Set FoundX = wsSource.Range("AI:AI").Find("TRUE", After:=wsSource.Range("AI" & Rows.Count), _
                                 LookAt:=xlPart, SearchDirection:=xlNext, MatchCase:=False)
    
    If FoundX Is Nothing Then
        
        Exit Sub
        
    Else
        
        
        Firstfound = FoundX.Address
        
        Lastrow = wsDest.Range("G" & Rows.Count).End(xlUp).Row + 1
        If Lastrow < 3 Then Lastrow = 3
        
        Do
            
            ' Need to Copy from Only rows 81:85 and I only need columns (AB, AC, AF & AG) '
            
            wsDest.Range("G" & Lastrow).Resize(1, 4).Value = FoundX.Offset(0, -5).Resize(1, 4).Value
            
            Lastrow = Lastrow + 1
            
            Set FoundX = wsSource.Range("AI:AI").FindNext(FoundX)
            
        Loop Until FoundX.Address = Firstfound
    
    End If



End Sub
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Just make the modifications in red:
Code:
Set FoundX = wsSource.Range("AI[COLOR=#b22222]81[/COLOR]:AI[COLOR=#b22222]85[/COLOR]").Find("TRUE", After:=wsSource.Range("AI[COLOR=#b22222]80[/COLOR]"), _
                                 LookAt:=xlPart, SearchDirection:=xlNext, MatchCase:=False)
 
Upvote 0
That worked great.... I forgot to remove '& Rows.Count' From the end of that line.... Now the only thing I need to do is pick only certain cells in those rows to copy over.
 
Upvote 0
Try replacing:

Code:
wsDest.Range("G" & Lastrow).Resize(1, 4).Value = FoundX.Offset(0, -5).Resize(1, 4).Value
with
Code:
wsDest.Range("G" & Lastrow).Resize(1, 2).Value = FoundX.Offset(0, -7).Resize(1, 2).Value
wsDest.Range("I" & Lastrow).Resize(1, 2).Value = FoundX.Offset(0, -3).Resize(1, 2).Value
 
Upvote 0
Thank You - That worked great.... I am still learning VBA by the old fashion (Trial and Error) Method.
 
Upvote 0

Forum statistics

Threads
1,203,399
Messages
6,055,174
Members
444,767
Latest member
bryandaniel5

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