loop Search, copy paste,next search, copy paste ...

Macrodroid

New Member
Joined
Nov 10, 2011
Messages
5
Hello everyone, I’m new to excel forums so bear with me on this one.

I’ve tried a bit of everything, but my programing skills with excel are limited.

The idea i have is the next:

Got 2 files:
1º - Where all the details are found and from where it will be extracted.
2º - Where the data will be copied to. The cell that was searched for, will be searched in this file too to paste

in other words, I need to be able to extract and make a loop search of all that is in Range(AH13:AH67) and for each that is found, run the code that comes after(or something similar)

Or that list or the list that’s in the file 1 in column AB to make the search faster.
(This last list has never the same amount of weeks and cells occupied. Only the ones illustrated in the document.)
Ill paste the code of what i intend to do

Hopfully ill just need to put some if's and then's around. :ROFLMAO:

Code:
[B][FONT=Arial][SIZE=2][COLOR=#000000]

Sub Copy1()
'
' Copy1 Macro
' Copy of planning
'
''''''
strName = Range("I3") 'Name of the user
StrFilePlan = Range("I5") 'Company time table
StrHojaPlan = Range("I6")  'Company time table page
strFileMio = Range("I4") 'Actual file name
strFileDIR = Range("I7") 'DIR Planning file


''''''''''''''''''''''''''''''''''''''''''''''''
'Search for week || copy and paste
''''''''''''''''''''''''''''''''''''''''''''''''

      Workbooks(StrFilePlan).Activate


    [A:Z].Find(What:="semaine 46", After:=ActiveCell, LookIn:=xlFormulas _
        , lookat:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Select

    Selection.Resize(Selection.Rows.Count + 1, _
        Selection.Columns.Count).Copy

''''''
'Paste
''''''

    Windows(strFileMio).Activate
    
    [A:Z].Find(What:="semaine 46", After:=ActiveCell, LookIn:=xlFormulas _
        , lookat:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Select
        
    ActiveSheet.Paste
    
    
''''''Search for user | Copy and Paste''''''

Workbooks(StrFilePlan).Activate

    '''Search for week entry
    [A:Z].Find(What:="semaine 46", After:=ActiveCell, LookIn:=xlFormulas _
        , lookat:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Select
        
    
        Selection.Resize(Selection.Rows.Count + 55, _
        Selection.Columns.Count).Select
        
    '''Search for name entry
    Selection.Find(What:=strName, After:=ActiveCell, LookIn:=xlFormulas _
        , lookat:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Select
        
        Selection.Resize(Selection.Rows.Count, _
        Selection.Columns.Count + 24).Copy
        
        
    Windows(strFileMio).Activate

    [A:Z].Find(What:="semaine 46", After:=ActiveCell, LookIn:=xlFormulas _
        , lookat:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Select
        
        ActiveCell.Offset(2, -1).Select
        ActiveSheet.Paste


End Sub
[/COLOR][/SIZE][/FONT][/B]
Ill appreciate all the help given
wink.gif


PD: sorry if ive spelled something wrong
 
Last edited:

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Corrected code of what i had but still no idea to do a seach with of multiple values:

Code:
Sub Copy1()
'
' Copy1 Macro
' Copy of planning
'
''''''
strName = Range("I3") 'Name of the user
StrFilePlan = Range("I5") 'Company time table
StrHojaPlan = Range("I6")  'Company time table page
strFileMio = Range("I4") 'Actual file name
strFileDIR = Range("I7") 'DIR Planning file


''''''''''''''''''''''''''''''''''''''''''''''''
'Search for week || copy and paste
''''''''''''''''''''''''''''''''''''''''''''''''


    Workbooks(StrFilePlan).Activate


    [A:Z].Find(What:="semaine 46", After:=ActiveCell, LookIn:=xlFormulas _
        , lookat:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Select

        Application.CutCopyMode = False
    Selection.Resize(Selection.Rows.Count + 1, _
        Selection.Columns.Count).Copy

''''''
'Paste
''''''

    Windows(strFileMio).Activate
    
    [A:Z].Find(What:="semaine 46", After:=ActiveCell, LookIn:=xlFormulas _
        , lookat:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Select
        
    ActiveSheet.Paste
    
    
''''''Search for user | Copy and Paste''''''

Workbooks(StrFilePlan).Activate
        Application.CutCopyMode = False
    '''Search for week entry
    [A:Z].Find(What:="semaine 46", After:=ActiveCell, LookIn:=xlFormulas _
        , lookat:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Select
        
        ActiveCell.Offset(0, -1).Select
        Selection.Resize(Selection.Rows.Count + 70, _
        Selection.Columns.Count).Select
        
    '''Search for name entry
    Selection.Find(What:=strName, After:=ActiveCell, LookIn:=xlFormulas _
        , lookat:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Select
        
        
        Selection.Resize(Selection.Rows.Count, _
        Selection.Columns.Count + 24).Copy
        
        
    Windows(strFileMio).Activate

    [A:Z].Find(What:="semaine 46", After:=ActiveCell, LookIn:=xlFormulas _
        , lookat:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Select
        
        ActiveCell.Offset(2, -1).Select
        ActiveSheet.Paste


End Sub
 
Upvote 0
This is what i intend but the code obviously doesn’t work.
Its just to get an idea of what I’m trying to do.

Code:
Sub Test()

Dim sCell As Range
Dim cValue, strName, strFilePlan, strHojaPlan, strFileMio, strFileDIR As String

''''''

strName = Range("I3") 
strFilePlan = Range("I5") 
strHojaPlan = Range("I6") 
strFileMio = Range("I4") 
strFileDIR = Range("I7") 

sCell = Sheets("Lista Horarios").Range("AH13")
cValue = sCell.Value

'''''''CODE''''''





Do Until cValue = ""

    Set s = [A:Z].Find(What:=cValue, After:=ActiveCell, LookIn:=xlFormulas _
        , lookat:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Select

    If Not s Is Nothing Then
            
            Application.CutCopyMode = False
            Selection.Resize(Selection.Rows.Count + 1, _
            Selection.Columns.Count).Copy
    
            ''''''''''''''''''''''''''''''''''''''''''''''''''
            ''''''''''  '''''''''''
            ''''''''''''''''''''''''''''''''''''''''''''''''''
            Windows(strFileMio).Activate
        
            [A:Z].Find(What:="cValue", After:=ActiveCell, LookIn:=xlFormulas _
                , lookat:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
                MatchCase:=False, SearchFormat:=False).Select
            
            ActiveSheet.Paste
        
        
            '''''''''''''
    
            Workbooks(strFilePlan).Activate
    
            Application.CutCopyMode = False
            
            '''Busqueda de semana
            [A:Z].Find(What:="cValue", After:=ActiveCell, LookIn:=xlFormulas _
                , lookat:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
                MatchCase:=False, SearchFormat:=False).Select
            
            ActiveCell.Offset(0, -1).Select
            Selection.Resize(Selection.Rows.Count + 70, _
            Selection.Columns.Count).Select
            
            '''Busqueda de nombre
            Selection.Find(What:=strName, After:=ActiveCell, LookIn:=xlFormulas _
                , lookat:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
                MatchCase:=False, SearchFormat:=False).Select
            
            
            Selection.Resize(Selection.Rows.Count, _
            Selection.Columns.Count + 24).Copy
            
            
            Windows(strFileMio).Activate
    
            [A:Z].Find(What:="cValue", After:=ActiveCell, LookIn:=xlFormulas _
                , lookat:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
                MatchCase:=False, SearchFormat:=False).Select
            
            ActiveCell.Offset(2, -1).Select
            ActiveSheet.Paste


    sCell = sCell.Offset(1, 0)
    
    End If

Loop


End Sub
<!--[if gte mso 9]><xml> <o:OfficeDocumentSettings> <o:AllowPNG/> </o:OfficeDocumentSettings> </xml><![endif]--><!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:TrackMoves/> <w:TrackFormatting/> <w:HyphenationZone>21</w:HyphenationZone> <w:PunctuationKerning/> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:DoNotPromoteQF/> <w:LidThemeOther>ES</w:LidThemeOther> <w:LidThemeAsian>X-NONE</w:LidThemeAsian> <w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript> <w:Compatibility> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:DontGrowAutofit/> <w:SplitPgBreakAndParaMark/> <w:EnableOpenTypeKerning/> <w:DontFlipMirrorIndents/> <w:OverrideTableStyleHps/> </w:Compatibility> <m:mathPr> <m:mathFont m:val="Cambria Math"/> <m:brkBin m:val="before"/> <m:brkBinSub m:val="--"/> <m:smallFrac m:val="off"/> <m:dispDef/> <m:lMargin m:val="0"/> <m:rMargin m:val="0"/> <m:defJc m:val="centerGroup"/> <m:wrapIndent m:val="1440"/> <m:intLim m:val="subSup"/> <m:naryLim m:val="undOvr"/> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true" DefSemiHidden="true" DefQFormat="false" DefPriority="99" LatentStyleCount="267"> <w:LsdException Locked="false" Priority="0" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Normal"/> <w:LsdException Locked="false" Priority="9" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="heading 1"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/> <w:LsdException Locked="false" Priority="39" Name="toc 1"/> <w:LsdException Locked="false" Priority="39" Name="toc 2"/> <w:LsdException Locked="false" Priority="39" Name="toc 3"/> <w:LsdException Locked="false" Priority="39" Name="toc 4"/> <w:LsdException Locked="false" Priority="39" Name="toc 5"/> <w:LsdException Locked="false" Priority="39" Name="toc 6"/> <w:LsdException Locked="false" Priority="39" Name="toc 7"/> <w:LsdException Locked="false" Priority="39" Name="toc 8"/> <w:LsdException Locked="false" Priority="39" Name="toc 9"/> <w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/> <w:LsdException Locked="false" Priority="10" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Title"/> <w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/> <w:LsdException Locked="false" Priority="11" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/> <w:LsdException Locked="false" Priority="22" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Strong"/> <w:LsdException Locked="false" Priority="20" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/> <w:LsdException Locked="false" Priority="59" SemiHidden="false" UnhideWhenUsed="false" Name="Table Grid"/> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/> <w:LsdException Locked="false" Priority="1" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 1"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 1"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 1"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/> <w:LsdException Locked="false" Priority="34" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/> <w:LsdException Locked="false" Priority="29" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Quote"/> <w:LsdException Locked="false" Priority="30" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 1"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 1"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 2"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 2"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 2"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 2"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 2"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 3"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 3"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 3"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 3"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 3"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 4"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 4"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 4"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 4"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 4"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 5"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 5"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 5"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 5"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 5"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 6"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 6"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 6"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 6"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 6"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/> <w:LsdException Locked="false" Priority="19" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/> <w:LsdException Locked="false" Priority="21" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/> <w:LsdException Locked="false" Priority="31" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/> <w:LsdException Locked="false" Priority="32" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/> <w:LsdException Locked="false" Priority="33" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Book Title"/> <w:LsdException Locked="false" Priority="37" Name="Bibliography"/> <w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/> </w:LatentStyles> </xml><![endif]--><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Tabla normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin-top:0cm; mso-para-margin-right:0cm; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0cm; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-fareast-language:EN-US;} </style> <![endif]-->
 
Upvote 0
Figured out this much so far.
Now i just need to make the search cell jump to the next cell, any ideas?

Code:
sCell = sCell.Offset(1, 0)
I dont know if i should be using the "offset" to change to the next cell.


This is what i got untill now:

Code:
Sub Test()

Dim sCell As Range
Dim cValue, strName, strFilePlan, strHojaPlan, strFileMio, strFileDIR As String
Dim Found As Range

''''''

strName = Range("I3") 
strFilePlan = Range("I5") 
strHojaPlan = Range("I6")  
strFileMio = Range("I4")
strFileDIR = Range("I7") 

Set sCell = Workbooks(strFileMio).Sheets("Lista Horarios").Range("AH13")
cValue = sCell.Value



'''''''CODE''''''





Do Until cValue = ""

    Workbooks(strFilePlan).Activate

        
      Set Found = [A:Z].Find(What:=cValue, After:=ActiveCell, LookIn:=xlFormulas _
        , lookat:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False)

    If Not Found Is Nothing Then
        With Found
        
            .Activate
            Application.CutCopyMode = False
            Selection.Resize(Selection.Rows.Count + 1, _
            Selection.Columns.Count).Copy
    
  
            '''''''''' Paste 
            
            Windows(strFileMio).Activate
        
            [A:Z].Find(What:=cValue, After:=ActiveCell, LookIn:=xlFormulas _
                , lookat:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
                MatchCase:=False, SearchFormat:=False).Select
            
            ActiveSheet.Paste
        
        
            '''''Copy of user''''
    
            Workbooks(strFilePlan).Activate
    
            Application.CutCopyMode = False
            
            '''Week search
            
            [A:Z].Find(What:=cValue, After:=ActiveCell, LookIn:=xlFormulas _
                , lookat:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
                MatchCase:=False, SearchFormat:=False).Select
            
            ActiveCell.Offset(0, -1).Select
            Selection.Resize(Selection.Rows.Count + 70, _
            Selection.Columns.Count).Select
            
            '''Name Search
            
            Selection.Find(What:=strName, After:=ActiveCell, LookIn:=xlFormulas _
                , lookat:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
                MatchCase:=False, SearchFormat:=False).Select
            
            
            Selection.Resize(Selection.Rows.Count, _
            Selection.Columns.Count + 24).Copy
            
            
            Windows(strFileMio).Activate
    
            [A:Z].Find(What:=cValue, After:=ActiveCell, LookIn:=xlFormulas _
                , lookat:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
                MatchCase:=False, SearchFormat:=False).Select
            
            ActiveCell.Offset(2, -1).Select
            ActiveSheet.Paste
            
        End With


    
    End If
    
    sCell = sCell.Offset(1, 0) 'Here is where i need to make and set sCell to the next cell for search

Loop


End Sub
 
Last edited:
Upvote 0
Ive SOLVED it and the bugs that came along.

Code:
Sub Download_Copy_Past()

Dim sCell As Range
Dim cValue, strName, strFilePlan, strHojaPlan, strFileMio, strFileDIR As String
Dim Found As Range

''''''Declaraciones

strName = Range("I3") 'Nombre del usuario en el planing '
strFilePlan = Range("I5") 'Planing Horario PSA '
strHojaPlan = Range("I6")  'Hoja Planing Horario PSA
strFileMio = Range("I4") 'Nuestra plantilla
strFileDIR = Range("I7") 'Directorio donde se encuentra el archivo

Set sCell = Workbooks(strFileMio).Sheets("Lista Horarios").Range("AH13")
cValue = sCell.Value


'''''''CODE''''''





Do Until cValue = ""

    Workbooks(strFilePlan).Activate
        
      Set Found = [A:Z].Find(What:=cValue, After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False)

    If Not Found Is Nothing Then
        With Found
        
            .Activate
            Application.CutCopyMode = False
            Selection.Resize(Selection.Rows.Count + 1, _
            Selection.Columns.Count).Copy
    
            ''''''''''''''''''''''''''''''''''''''''''''''''''
            '''''''''' Pega en celdas seleccionada '''''''''''
            ''''''''''''''''''''''''''''''''''''''''''''''''''
            Windows(strFileMio).Activate
            
            Range("C12").Select
            [A:Z].Find(What:=cValue, After:=ActiveCell, LookIn:=xlFormulas, _
                LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
                MatchCase:=False, SearchFormat:=False).Select
                
            
            ActiveSheet.Paste
        
        
            '''''COPIA DE HORAS USUARIO''''
    
            Workbooks(strFilePlan).Activate
    
            Application.CutCopyMode = False
            
            '''Busqueda de semana
            [A:Z].Find(What:=cValue, After:=ActiveCell, LookIn:=xlFormulas, _
                LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
                MatchCase:=False, SearchFormat:=False).Select
            
            ActiveCell.Offset(0, -1).Select
            Selection.Resize(Selection.Rows.Count + 70, _
            Selection.Columns.Count).Select
            
            '''Busqueda de nombre
            Selection.Find(What:=strName, After:=ActiveCell, LookIn:=xlFormulas _
                , LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
                MatchCase:=False, SearchFormat:=False).Select
            
            
            Selection.Resize(Selection.Rows.Count, _
            Selection.Columns.Count + 24).Copy
            
            
            Windows(strFileMio).Activate
    
            [A:Z].Find(What:=cValue, After:=ActiveCell, LookIn:=xlFormulas, _
                LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
                MatchCase:=False, SearchFormat:=False).Select
            
            ActiveCell.Offset(2, -1).Select
            ActiveSheet.Paste
            
        End With


    
    End If
    
   Set sCell = sCell.Offset(1, 0)
   cValue = sCell.Value

Loop


End Sub
 
Upvote 0

Forum statistics

Threads
1,203,124
Messages
6,053,643
Members
444,675
Latest member
FedElecQaEng

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