+ Reply to Thread
Results 1 to 3 of 3

vba macro

  1. #1
    Registered User
    Join Date
    05-10-2010
    Location
    Minnesota
    MS-Off Ver
    Excel 2003
    Posts
    1

    vba macro

    Hello, I am trying to use this vba macro that I got off the internet it does exactly what I want it to do, but I do not know how to setup it up here is the code.

    Sub Find_Data()
    ' Written by Barrie Davidson
    Dim datatoFind
    Dim sheetCount As Integer
    Dim counter As Integer
    Dim currentSheet As Integer

    On Error Resume Next
    currentSheet = ActiveSheet.Index
    datatoFind = InputBox("Please enter the value to search for")
    If datatoFind = "" Then Exit Sub
    sheetCount = ActiveWorkbook.Sheets.Count
    If IsError(CDbl(datatoFind)) = False Then datatoFind = CDbl(datatoFind)
    For counter = 1 To sheetCount
    Sheets(counter).Activate
    Cells.Find(What:=datatoFind, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
    :=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
    False).Activate
    If ActiveCell.Value = datatoFind Then Exit Sub
    Next counter
    If ActiveCell.Value <> datatoFind Then
    MsgBox ("Value not found")
    Sheets(currentSheet).Activate
    End If
    End Sub

    Here is the thing, I open up the vba editor and copy and paste that code, when I run the script I get a user form and it is blank and has nothing in it do I need to make a Input Box or something to make this work? What the code is suppose to do is I run it and it asks me for input and I type a name or data and it finds it in all the worksheets I have. and put the data on a separate worksheet . If anybody could help me asap that would be great. thanks

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: vba macro

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.
    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: vba macro

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

+ 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