+ Reply to Thread
Results 1 to 2 of 2

Thread: Interactive Macros

  1. #1
    Registered User
    Join Date
    07-22-2011
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Interactive Macros

    Where can I get help on setting up interactive macros? I want to be able to input data to a macro or specify a particular range in another worksheet to get or paste data.

  2. #2
    Forum Guru Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,023

    Re: Interactive Macros

    Macro's will just run to the end unless you pause them some way, so to this end they're not interactive, but, you can introduce input boxes along the way like this
    'code supplied by Simon Lloyd
    '22/07/2011
    Microsoft Office Help
    Sub Macro1()
    Dim Rng As Range, MyCell As Range, oCell As Range
    Dim i As Long, iR As Long, IB As String
    i = 1
    iR = 3
    Set Rng = Range("A1:A10")
    For Each MyCell In Rng
    MyCell.Interior.ColorIndex = i
    If i = 3 Then
    IB = Application.InputBox("Enter a name", "Name Collection")
    MyCell = IB
    ElseIf i = 6 Then
    IB = Application.InputBox("Enter a Range like B1 or B2:C5", "Range Collection")
    For Each oCell In Range(IB)
    oCell.Interior.ColorIndex = iR
    iR = iR + 1
    Next oCell
    End If
    i = i + 1
    Next MyCell
    End Sub
    Just for fun
    Not all forums are the same - seek and you shall find

+ 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.2.0