+ Reply to Thread
Results 1 to 3 of 3

After the "Find" function in VBA......

Hybrid View

  1. #1
    Registered User
    Join Date
    01-26-2012
    Location
    Eden Praire
    MS-Off Ver
    Excel 2007
    Posts
    8

    After the "Find" function in VBA......

    I have a Find function used in conjuction with unhiding a sheet, the Find function works, but you have to scroll to find the cell. When you use the "Find" function in Excel it scrolls to the cell and centers it in view, but in the macro it just goes to the cell, but not in view.....any help will be great.

    Thanks,
    Application.ScreenUpdating = False
    Sheets("Sheet1").Visible = True
    Sheets("Sheet1").Select
    Range("A1").Select
    Cells.Find(What:="1", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
            xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
            False, SearchFormat:=False).Activate       
    Application.ScreenUpdating = True
    
    End Sub


    End Sub
    Last edited by Kimber20; 05-13-2012 at 01:20 AM.

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

    Re: Hope this help!

    Option Explicit
    Sub GPE_COM()
     Dim Rng As Range, sRng As Range
     Dim MyAdd As String
    
     With Sheets("Sheet1")
        .Visible = True
        Set Rng = .Range("A1").CurrentRegion
        Rng.Interior.ColorIndex = 0
        Set sRng = Rng.Find(What:="1", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
            xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
            False, SearchFormat:=False)
        If Not sRng Is Nothing Then
            MyAdd = sRng.Address
            Do
                sRng.Interior.ColorIndex = 35
                Set sRng = Rng.FindNext(sRng)
            Loop While Not sRng Is Nothing And sRng.Address <> MyAdd
        End If
     End With
    End Sub
    Last edited by Paul; 05-13-2012 at 11:53 AM. Reason: Changed PHP tags to CODE tags.

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

    Re: Use FIND() methode in UDF

    Option Explicit
    Function Count_1_InColumnA(Rng As Range)
     
     Dim Cls As Range, sRng As Range
     Dim Rws As Long
     
     Rws = Rng.Cells.Count
     Set sRng = Rng.Find(1, , xlFormulas, xlWhole)
     If Not sRng Is Nothing Then
        For Each Cls In Range(sRng.Offset(-1), Rng(Rws))
            If Cls.Value = 1 Then Count_1_InColumnA = 1 + Count_1_InColumnA
        Next Cls
     End If
    End Function
    =Count_1_incolumnA(A2:A35)
    Last edited by Paul; 05-13-2012 at 11:53 AM. Reason: Changed PHP tags to CODE tags.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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