Results 1 to 3 of 3

Automatically Scroll Window as Macro Runs

Threaded View

  1. #1
    Registered User
    Join Date
    06-27-2014
    Location
    UK
    MS-Off Ver
    Pro 2003
    Posts
    13

    Automatically Scroll Window as Macro Runs

    Just for a bit of fun (and to see how calculations were working out), I was trying to get a macro to scroll down the window as it calculated data.


    Sadly, ActiveWindow.SmallScroll Down:=2 was too fast and =1 was too slow!

    More sadly, that's the only command I know to get this to work.


    So, I'm hoping for a demonstration of a different command. Can anyone recommend a way to get the window to scroll automatically to the cell which has just had information inserted into it?

    Here's the VBA (kindly bestowed upon me by MickG) :


    Sub CustomerCategory()

    Dim Rng As Range
    Dim Dn As Range
    Dim n As Long
    Dim Rng2 As Range
    Dim Data As Variant
    Dim Temp As String
    Dim K As Variant
    Dim Str As String
    Dim oMax As Integer
    Dim Dn2 As Range

    With Sheets("Brand Categories")
    Set Rng2 = .Range(.Range("A1"), .Range("A" & Rows.Count).End(xlUp))
    End With
    With ActiveSheet
    Set Rng = .Range(.Range("A2"), .Range("A" & Rows.Count).End(xlUp))
    End With


    With CreateObject("scripting.dictionary")
    .CompareMode = vbTextCompare
    For Each Dn In Rng
    If Not Dn.Value = vbNullString Then
    For Each Dn2 In Rng2: .Item(Dn2.Value) = Empty: Next Dn2
    Data = Split(Dn, ";")
    For n = 0 To UBound(Data)
    If .Exists(Data(n)) Then
    .Item(Data(n)) = .Item(Data(n)) + 1
    End If
    Next n

    For Each K In .keys
    If Not .Item(K) = "" Then
    oMax = Application.Max(oMax, .Item(K))
    If .Item(K) = oMax Then Temp = K
    Str = Str & K & "(" & .Item(K) & "); "
    End If

    On Error Resume Next

    Next K

    Dn.Value = Str
    Dn.Offset(, 1) = Rng2(Application.Match(Temp, Rng2, 0), 2)
    Str = "": Temp = "": oMax = 0: .RemoveAll

    'ActiveWindow.SmallScroll Down:=2

    End If
    Next Dn
    End With

    End Sub
    Last edited by The831st; 07-31-2014 at 11:50 AM. Reason: SOLVED

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Insert scroll bar and update cells when clicking on item in scroll bar window
    By kosherboy in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-10-2014, 03:53 PM
  2. When executing macro via hyperlink, macro doesn't re-scroll window back to A1
    By rain4u in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-15-2011, 02:30 PM
  3. Can you exclude coloums from a macro that runs automatically?
    By snoopy1461 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-31-2011, 09:37 AM
  4. Macro automatically runs report
    By yes sir in forum Access Tables & Databases
    Replies: 9
    Last Post: 08-26-2010, 04:15 PM
  5. Macro that runs automatically?
    By Johann in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-01-2006, 09:20 AM

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