+ Reply to Thread
Results 1 to 3 of 3

Need help amending a find and mark macro.

  1. #1
    Registered User
    Join Date
    08-12-2009
    Location
    Cardiff, Wales
    MS-Off Ver
    Excel 2007
    Posts
    53

    Need help amending a find and mark macro.

    Right, with the help of rondebruin, I have made a start. But still need help fine tunning it.
    Need to change the search criteria? Need to search for more values, but cant seem to get it to work.
    Also it searches for blank cells at the moment, how do I stop this? And it only searches one sheet? Cant seem to amend this for multiple sheets.
    Someone Please help! My Vba is rubbish, but im really trying on this one
    See code so far:
    Please Login or Register  to view this content.
    This was posted in one of my previous posts, but no luck so far. If you look at my previous post you can see an explanation of what I need it to do. Thanks

  2. #2
    Forum Contributor
    Join Date
    03-21-2012
    Location
    Ho Chi Minh city
    MS-Off Ver
    Excel 2003
    Posts
    180

    Re: Need help amending a find and mark macro.

    PHP Code: 
    Option Explicit
    Sub Mark_Cells_In_Column
    ()
     
    Dim FirstAddress As StringAs Long
     Dim MyArr 
    As VariantRng As RangeSh As Worksheet

     Sheets
    ("Sheet1").Select
     With Application
        
    .ScreenUpdating False
        
    .EnableEvents False
     End With
     MyArr 
    = Array(Range("A1").ValueRange("A2").Value)
     For 
    Each Sh In ThisWorkbook.Worksheets
        
    If Sh.Name <> "Sheet1" Then
            With Sh
    .Range("A:A")
                .
    Offset(01).ClearContents
                
    For LBound(MyArrTo UBound(MyArr)
                    
    Set Rng = .Find(What:=MyArr(I), After:=.Cells(.Cells.Count), _
                        LookIn
    :=xlFormulasLookAt:=xlWholeSearchOrder:=xlByRows_
                        SearchDirection
    :=xlNextMatchCase:=False)
                    If 
    Not Rng Is Nothing Then
                        FirstAddress 
    Rng.Address
                        
    Do
                            
    Rng.Offset(01).Value Range("B1").Value  'B1<=|'
                            
    Rng.Offset(02).Value Range("C1").Value  'C1<=|'
                            
    Set Rng = .FindNext(Rng)
                        
    Loop While Not Rng Is Nothing And Rng.Address <> FirstAddress
                    End 
    If
                
    Next I
            End With
        End 
    If
     
    Next Sh
     With Application
        
    .ScreenUpdating True
        
    .EnableEvents True
     End With
    End Sub 

  3. #3
    Registered User
    Join Date
    08-12-2009
    Location
    Cardiff, Wales
    MS-Off Ver
    Excel 2007
    Posts
    53

    Re: Need help amending a find and mark macro.

    Hi, thanks, this seems to work great for multiple sheets. Is there a way to prevent it from searching if the cell is blank. Eventually I plan on having approximatelly 20 cells for search. eg MyArr=A1,A2,A3.........A20, so if cells A1 to A5 contain a value but A6 to A20 dont, then only want it to find the cells that are populated. At the moment if I have a value in A1 and nothing in A2 then it trys to add the values from B1 and C1 to the right of all the blank cells in column A on every worksheet (currently 250).
    Thanks again.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1