+ Reply to Thread
Results 1 to 2 of 2

Combining two macros ( user input & search/copy results)

  1. #1
    Registered User
    Join Date
    10-12-2009
    Location
    london
    MS-Off Ver
    Excel 2007
    Posts
    1

    Combining two macros ( user input & search/copy results)

    Hi all,

    I am new to excel 2007 and macro's, I have used couple of macros and would like to combine them together..please help

    Excel 2007
    1st macro

    Public Sub MyInputBox()

    Dim MyInput As String
    MyInput = InputBox("This is my InputBox", _
    "MyInputTitle", "Enter your input text HERE")

    If MyInput = "Enter your input text HERE" Or _
    MyInput = "" Then
    Exit Sub
    End If

    MsgBox "The text from MyInputBox is " & MyInput

    End Sub


    It prompts a box for user input and display the input

    2nd macro

    Sub Test1()
    Application.ScreenUpdating = True
    Dim xRow&, NextRow&, LastRow&
    NextRow = 2
    LastRow = Cells.Find(What:="*", After:=Range("A1"), SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    For xRow = 1 To LastRow
    If WorksheetFunction.CountIf(Rows(xRow), "*hello*") > 0 Then
    Rows(xRow).Copy Sheets("Sheet2").Rows(NextRow)
    NextRow = NextRow + 1
    End If
    Next xRow
    Application.ScreenUpdating = True
    End Sub


    It searches spreadsheet for keyword and compy the rows having the keywork into another workbook.

    My dream for now - I would want it to prompt for user input, then search the keyword and copies the result into new workbook.

    This will make my life lot easier, I have spent lot of time and always get error cos i don't know how vb works, any help would be of gr8 help.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Combining two macros ( user input & search/copy results)

    Welcome to the forum.

    Please take a few minutes to read the forum rules, and then edit your post to add code tags.

    Thanks.
    Entia non sunt multiplicanda sine necessitate

+ 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